Hi,
i have a script with a custom inspector; in this inspector i use a button to gather some data (multiple instances of a very simple custom [serializable]-attributed class) and store that in a public list of the inspected component.
I’m not using serializedObject with the serializedproperty GUI/drawers in the custom inspector but the plain casted reference to the component to access its fields ( (mycomponent)target ).
I even added a SetDirty call, but the data won’t persist.
The GameObject resides in the hierarchy, it’s not a prefab.
The serialized data survives playmode but not editor restart and that irritates me.
Is there anything i missed?
i’m expecting this data to be saved just as i do when changing other basic variables on Gameobjects in the scene (they are serialized into the scene stream, no?)
Edit: retrying several times, at some point it now randomly did retain the values between restarts but then new ones are still not replacing those (after restart the previous values are restored).
After further tests: new values are only saved while i create a prefab of the gameobject. I can even delete the prefab directly after creating it, so it doesn’t look like the object just gets those values from the prefab.
Since Unity 5.3, SetDirty doesn’t mark scene objects as dirty. Using the serialized object representation is the preferred way to go. But if you really don’t want to do that, use Undo.RecordObject() before making changes.