Home > database >  How to call external class method from InlineButton attribute in Odin Inspector?
How to call external class method from InlineButton attribute in Odin Inspector?

Time:06-24

I'm tried to write a UtilityClass using Odin Inspector.

public static class UtilityClass
{
  public static void Select(Component obj)
  {
    UnityEditor.Selection.activeObject = obj.gameObject;
  }
}

And I tried to call that method on InlineButton.

[InlineButton("UtilityClass.Select", "Select")]
public Canvas canvas;

However, I get the following error:

Couldn't not match the given string 'UtilityClass.Select' to any action that can be performed in the context of the type 'Test'. The following kinds of actions are possible:

Since Odin Inspector is implemented with reflection, I think it is a natural problem.

But, is there really no way to call an external method like the one above?

CodePudding user response:

@Schwapo from SIRENIX responded.


Yes, if it's static you can just do

[InlineButton("@SomeExternalClass.SomeStaticFunction()")]

If it's not static you'll need a reference to the external class.


  • Related