im not a good programmer, but adding a name into a function is maybe too much… i add a scriptable object for each action, now holding name and icon image only, but can be easily added or changed…
You mean you made a field in the action class for a scriptable object that contains the name and icon?
The issue with that is you can use different scriptable objects on the same action. So you might have two move actions but one is called “move” and another is called “run” despite the fact that the underlying logic is exactly the same.
yes, i must take care about it its totally ok in script, no1 will change it, im just thinking about UI description, maybe different actions will cost different action points and so on… and make it a bit different… not just ctrl+c… ctrl+v…
Is that really a problem though or is it more actually a feature? I think it makes sense to be able to swap visuals and labels for different prefabs without the need to create a completely new script for that. For example, I might have different factions in my game and want to use different icon sets for their actions even though the move action uses the same script for both.
Another advantage of the scriptable object approach is that the code lives completely in the BaseAction class (or rather in the scriptable object class) and there is no need for additional implementation inside each individual Action script that can then fully focus on the action mechanic independent of how the visuals/labels are used. For example, I don’t have to change each action script if I, later on, decide to add a short tooltip description window for each action.
As always it depends on what design you’re trying to implement.
For the design that I was going for it didn’t make sense to have actions with the exact same logic but different name. If a MoveAction always does the exact same MoveAction then I want it to always show “Move”
If for example you added some SerializeField’s that modified the behaviour of the action on a per instance basis then I could see that being useful since the logic would change depending on the values you selected for that particular action so in that case it could make sense to have a different name.