Detecting a change on an editor script GUI Field.

Hi there,

Just been getting into editor scripts a little and I was stuck on this.
Is there a way to run a function when a field like this is changed?

matColor = EditorGUILayout.ColorField("New Color", matColor);

It’s super easy with a button

 if (GUILayout.Button("Change!"))

But for something like this I’m comparing colours to see if they have changed and it feels like there might be a better way.

Any ideas?

Thanks,
Pete

There’s a few way to detect changes, I prefer EditorGUI.BeginChangeCheck, but there’s also EditorGUI.ChangeCheckScope and GUI.changed.

Awesome! Thank you @Adrian