- Home /
Question by
Karsnen_2 · Oct 07, 2014 at 01:42 PM ·
c#inspectorserialization
How to control serialized variables over the inspector pane?
Hello,
SCENARIO :
Lets say that there is a class like http://pastebin.com/sem7hfn4 And I want to expose the variable StartTime only when the TypeOfState for thisState is Start
How do I achieve this? If the question requires a long answer - please spot me towards a tutorial (prefer) or a resource online where I could learn that from?
Thank you and I appreciate your time.
Karsnen
Comment
Answer by EvilTak · Oct 07, 2014 at 02:09 PM
You will have to create a custom editor script for that. If you don't know how to make one, you can easily find many tutorials by a simple Google search. The code to do what you require could be as follows:
if (serializedPropertyOfThisState.enumValueIndex == 0) { //serializedPropertyOfThisState is the serialized property of variable thisState (check SerializedProperty in docs
StartTime = EditorGUILayout.FloatField(StartTime);
}
Well, that is a start. I am going to find what I can do with it.