- Home /
EditorGUI.IntField always 0 after GameStart
Hi,
I've created a CustomPropertyDrawer to show a String array like an enum (for a dropdown list etc), I also have some EditorGUI.IntField, which will be created through entrys in an array (there could be more than one). I'm creating it like this way (parameterList is an object array, thats why I need the convert, later I also want to save there strings etc and create the list dynamically)
int parameterValue = Convert.ToInt32(parameterList[i]);
parameterList[i] = EditorGUI.IntField(pos,tempParamters[i].Name, parameterValue);
In the editor it look then like this
If I change the value in the inspector, everything works, its saved, even if I reclick it. But when I start the game, it will be reseted to 0.
How can I get this work?
This is a serialization issue. You can try to put the [SerializeField] attribute above your array (and all other variables you want to survive serialization) and [System.Serializable] above your class definition. Then hope Unity serializes everything properly.
If that doesn't work, you'll need to do some googling regarding Unity Serialization
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Custom Inspector & Arrays 0 Answers
Destroying Elements From An Array 1 Answer
Getting information from an array 1 Answer
Custom PropertyDrawer for attributes on array members 2 Answers