- Home /
Editor changes lost when entering Playmode
I'm certain I'm misunderstanding how Unity's serialization works but when i enter play mode all changes made through my custom editor are instantly reverted to the last value before the editor made its changes. i.e my editor changes a public int from a GameObject from 50 to 72 when entering play mode the value becomes 50 again, if i change the value manually the value will remain the correct value(72). Just to be clear the editor works exactly as expected.
cutting my code back to the relevant points i have the following setup
[CustomEditor (typeof(WayPoint))]
public class WaypointController : Editor
{
foreach (GameObject o in SelectedWaypoints)
{
o.GetComponent<WayPoint>().Priority = 72;
EditorUtility.SetDirty(o);
}
}
[System.Serializable]
public class WayPoint : MonoBehaviour
{
[SerializeField]
public int
Priority;
}
my understanding is that atomic types such as int shouldn't need to be tagged in this manner but I simply can't get changes made by my editor class to be serialized.
Thanks in advance for any and all help.
Your answer
Follow this Question
Related Questions
Custom editor, serialize and prefab issue 0 Answers
Efficiently serializing large collision grid 2 Answers
PropertyField for a list marked with [HideInInspector] 1 Answer
Data of prefab is not being saved on play mode despite serialization. 1 Answer
ScriptableObject with Custom Editor resetting data in inspector 1 Answer