Expose method with Enum parameter to editor
I have the following method:
public void Play(PlayModes mode)
{
// ...
}
I would like to expose this method to the editor so I can assign it to various buttons. It seems because it takes an enum
parameter, the editor does not display it.
What do I need to do to fix this?
I'm trying to do this right now, so I can select an enum value when invoking the method from an Event Trigger component. It doesn't seem to matter where the enum is created, Unity just rejects any functions that require an enum as an argument. But setting an enum attribute for a component is handled just fine. I guess for now I'm going to have to write a different function for each enum value and invoke my main function passing the enum from there.
You can use int as an alternative. Just assign a fixed number to the enum.
Yeah, I know, but that doesn't make it user friendly to the other developers in my $$anonymous$$m who might not know which int to use for each enum item. At least with a function for each enum the function names can be human readable
The enum was defined in a component cs file, but outside of the component class. As far as I'm aware that makes it a global enum.