- Home /
Script (with custom inspector) Variables Reset on Play
Values assigned to my script's variables will not persist after hitting the Preview button in Unity 4.3.4f1
I have tried adding the line EditorGUIUtility.SetDirty( target ) to the custom inspector script.
The fields being reset are not of a custom type (ie, even booleans, strings, floats, etc. are losing their values, as well as references to objects in the scene and/or project hierarchy).
Answer by dmg0600 · Sep 19, 2014 at 03:22 PM
In Unity lick on Assets and then on Reimport All. Close Unity and start it again.
It seems that it is not saving the changes of the scripts and it just keeps an old version.
Wouldn't this just make sure the code itself was up-to-date? I'm talking about the values seen in the inspector when I add this script to a GameObject. I'll add it, tweak the values, hit Preview, and immediately they are all reset to their default values.
Yes, but it happens some times that it does not update the scripts and values in general so if you change the values in the inspector and hit play it will be as if you have done nothing. Can't tell in what specific case it happens but I've seen it several times and reimporting and restarting worked perfectly.
Your answer
Follow this Question
Related Questions
Character motor script resets when I play 1 Answer
Inspector value resets on prefabs 1 Answer
Saving changes while playing... 1 Answer
How to play a ParticleSystem just once when a certain value is reached 2 Answers
play animation with script 4 Answers