Instead of having the GetActionName then having to generate the method in each of the MoveAction and SpinAction scripts. I found it much simpler to just do the following:
With that you can indeed set the name in the Editor, however it also means you can give the exact same Action class a different name which would be very confusing. Whereas if you define the name in the code then all instances of that class will share the same name.
One other problem with this solution in this specific case is that you lose the compiler warnings when you forgot to change the name for a new action. (As in, if you just don’t define GetActionName() in a new class when the method is purely abstract the compiler would warn you, but with this you have no warning).
But on the other hand your solution might be pretty useful for debugging, so may still be worth it sometimes
something here Im worried about is translation.
I guess you would call the name from another script on the return once you start dealing with that sort of stuff
@Gamesdisk This is actually easy to implement when you have a method that is called to get the label. Instead, you just get the label from your localisation system and return that. If you use a serialized field to be able to set it in the editor, getting a localised string is less simple. So, I would not worry about that.
Indeed, it would be the UI method’s responsibility to take care of handling localization by querying the localization system “hey, what’s the label string to put on a button for a MOVE action?”
In a more complex UI system one might have some base class for standard elements that would have some UpdateLabel() method calling for the localized string, so it would be all in one place…