- Home /
Custom Editor window loses values on play.
I'm making an Item Editor that needs the use of play mode to be fully used (UMA runtime building).
I've noticed this as a problem for a while but it hasn't been a real problem until now. Upon rebuilding scripts or playing the scene my custom editors would lose their values/variables when they were open, therefore since there are no default values it would crash when these values are lost.
I'm wondering as to why this is or how to get around this.
Answer by Bunny83 · Apr 14, 2018 at 11:51 PM
When you start playmore or when any scripts are recompiled the whole environment is serialized, shut down, reloaded and deserialized. If your editor references any values / objects that are not serializable by Unity they will be lost.
The solution is to make sure all your values are actually serialized. If you have some data that can't be serialized by Unity you can use the ISerializationCallbackReceiver interface and manually convert your necessary data into some data structures that Unity can serialize.
Without more information on what "data" you talk about we can't help you any further.