Help on GUI.Changed(), Serialized properties and Undo

In a custom editor, I have several serialized properties. As expect when I change any of them, GUI.Changed is set to true.

However, if I undo a change, the value(s) for whatever serialized property was changed is reflected in the custom editor but as this value is changed, the GUI.Changed is never set. How do I detect when a value in a serialized property has been changed as a result of an undo operation?

I thought serialized properties handled that automatically… what am i missing here?

You should really check out the CatlikeCoding tutorials on this subject:

It’s related to BeginProperty method:

label = EditorGUI.BeginProperty(position, label, property);
EditorGUI.Foldout(foldoutPosition, property.isExpanded, label, true);
EditorGUI.EndProperty();

Cheers,

1 Like

CatLikeCoding does have good tutorials but that is not the issue I am having.

What I am describing is whenever an Undo / Redo is performed, other than checking for Event.current.commandName to see if it matches “UndoRedoPerformed”, there isn’t anyway (that I know) of detecting that an Undo / Redo was performed which affected some serialized property.

Unless, I am missing something, it seems that whenever an Undo / Redo is performed on some serialized fields / properties, it should set GUI.changed = true to make it easier to detect whenever it occurs.

P.S. CatLikeCoding did use this technique in one of his tutorials but having to do this seems a round about way to get there.

Ten year anniversary of this thread but I am struggling with this same thing! Any updates/suggestions?