- Home /
Overriding an inherited Enum?
Hello! My question is short, but maybe tough or impossible, I'm not sure.
I have a class like so.
public class Entity_Controller : MonoBehaviour {
public enum states_enum{};
}
I have a class that inherits from it.
public class Player_Controller : Entity_Controller {
public new enum states_enum {
idle,
walk,
run
}
}
The thing is I get errors saying I cannot override it or do stuff like it and have found nothing online for it, making me think it might be impossible.
What I want to do with this is to have classes like goblin_controller, bat_controller, player_controller inheriting from entity_controller. Each of them might have different possible states that I would like to initialize in their respective classes. Thanks for reading.
Answer by mikawendt · Oct 20, 2019 at 11:55 PM
Why not have a universal enum for all possible animations
then for each entity, you can have a List and add the enums that is relevant for that specific entity?
So simple, why didn't I think of that. Split them in a List but keep them ALL in one. Thank you very much. I added a comment to make sure I don't change it later. It says "// Enums of all possible state indexes of any possible instance."
Your answer
Follow this Question
Related Questions
How to make classes in C# that are assignable to public variables in scripts trough the Editor 1 Answer
Inherited class, trying to overwrite variable. 0 Answers
How to prevent an inherited variable from showing up on a scriptable object? 1 Answer
Why is Start() from my base class ignored in my sub-class? 4 Answers
Enums and Class - A general question 0 Answers