The following code is a snippet of how I'm auto-updating an object whenever a setting changes in the inspector window (for a scriptable object). It's currently not working, but It will work if I put the two lines Editor editor... and editor.OnIns... inside the using block. I'm confused on why this is.
public void DrawSettingsEditor(Object settings, System.Action onSettingsUpdate)
{
Editor editor = CreateEditor(settings);
editor.OnInspectorGUI();
using (var check = new EditorGUI.ChangeCheckScope())
{
if (check.changed)
{
onSettingsUpdate();
}
}
}
See https://pastebin.com/d0NumWZv for all the code for this class.