Detect Inspector ScriptableObject Dirty
What is the simplest way to detect if a ScriptableObject has been changed in the inspector. I need to run a JSON serializer whenever something changes. Being able to auto detect the change would be much easier than having a user click a save button.
Answer by Glurth · Jul 25, 2016 at 06:08 PM
Perhaps this will suit your needs? https://docs.unity3d.com/ScriptReference/GUI-changed.html
for a more limited variant: https://docs.unity3d.com/ScriptReference/EditorGUI.BeginChangeCheck.html
Obviously these wont detect changes you make in code, but they can detected changes made by the user, in Inspector controls.
I thought about this first actually. The catch would be having to write a custom inspector. Is it possible to just wrap the default inspector with a custom inspector that detects changes?
I would think so. I would call DrawDefaultInspector in your Custom Editor's OnInspetorGUI function to make it do all the drawing. Just make sure it's after BeginChangeCheck, and before EndChangeCheck. Never tried it tho. https://docs.unity3d.com/ScriptReference/Editor.DrawDefaultInspector.html