Firstly, sorry for the long winded title - I couldn’t think of a more concise way to write it down.
Basically I have a method which uses reflection to retrieve a class by its code name and I need to access one of the class’s variables to do some checks with it.
I suppose I could either convert from System.Type to State or try to access IsDefault by using its code name like I did with the class however I’m not too familiar with reflection to know what’s possible and not.
Here is the code in question:
public void PushState(string Name) { Type type_state = Type.GetType(Name); if(type_state.IsDefault) StatesContainer.Insert(0, type_state); //Default state will always be found at Index 0 else StatesContainer.Add(type_state); }
As it stands now, Unity is looking for IsDefault in System.Type instead of State, which obviously throws an error. What would be the best way to access IsDefault?
EDIT: Forgot to mention that “State” is a class, in case my wording wasn’t too clear.