- Home /
Custom inspector variable resets automatically
I am trying to make a custom script that allows to spawn prefabs from the editor (without enetering play mode). In this editor there is a field like this:
Vector3 spawnPosition = Vector3.zero;
Whenever I change the focus on the script, or I click play or stop, the field gets reset.
I have been looking on the internet and the clasic solutions doesn't seem to work anymore. Examples:
Adding [SerializeField] to the variable
Adding [System.Serializable] the the class
Removing = Vector3.zero; from the declaration
Invoking EditorUtility.SetDirty(target);
Since the variables are from the custom editor and not the script, this doesn't work neither: SerializedProperty
The class works fine but the custom variables get reset all the time which is very anoying.
Did anyone else run into the same problem? Thanks
After making changes you need to call the method [i dont remember the name] Apply$$anonymous$$odifiers() or something like that, and then it will apply changes.