0
\$\begingroup\$

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.

\$\endgroup\$
3
  • 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\$ Commented Dec 31, 2020 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\$ Commented Dec 31, 2020 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\$ Commented Dec 31, 2020 at 4:27

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.