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);

        using (var check = new EditorGUI.ChangeCheckScope())
            if (check.changed)

See https://pastebin.com/d0NumWZv for all the code for this class.

  • 1
    \$\begingroup\$ This seems to follow pretty directly from the documented example of how to use ChangeCheckScope. Can you clarify, why would you expect this to work differently? \$\endgroup\$ – DMGregory Dec 31 '20 at 4:19
  • \$\begingroup\$ Oh looks like I didn't read the docs. I was following from a tutorial that used this code block. Thanks. \$\endgroup\$ – Shrey Joshi Dec 31 '20 at 4:24
  • 2
    \$\begingroup\$ In future, when you have a question about how an API works, please start by consulting that API's documentation first. It will save you time. \$\endgroup\$ – DMGregory Dec 31 '20 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.