Is there a method that gets constantly updated in the editor?

Hey folks.

I finally found out how to use the 3rd and 4th MouseButtons, but now I need to constantly check for them.

Problem is I don’t know of any method besides [ExecuteInEditMode], but actually I really don’t want to use a GameObject and MonoBehaviour just for that ( just turned all of my Singletons to ScriptableObjects).

isn’t there some magical Method or Class out there, that could help me out?

Thanks

2 Answers

2

UnityEditor.EditorApplication.update

    [UnityEditor.InitializeOnLoad] // <<< IMPORTANT
    public class TestClass
    {
      static TestClass()
      {
        UnityEditor.EditorApplication.update += MyMethod;
      }

      private static void MyMethod()
      {
        Debug.Log("MyMethod!");
      }
    }

You may want to wrap the whole script in a preprocessor [hashsymbol]IF UNITY_EDITOR ... [hashsymbol]ENDIF to avoid build errors

Nice, this looks good. Actually I went for EditorWindow, but this method looks way better. I check it out tomorrow. Thanks Buddy ;-) But one Question: When do you prefer InitializeOnLoad over DidReloadScripts? Ah and yeah, I forgot to tell you but It should've been an editor Script. But if I ever intent to use a combo, I know where to look ;-)

use this:

 [ExecuteInEditMode]
    public class PrintAwake : MonoBehaviour
    {
        void Awake()
        {
            Debug.Log("Editor causes this Awake");
        }
    
        void Update()
        {
            Debug.Log("Editor causes this Update");
        }
    }

Found Here

Note you can remove MonoBehaviour

Nope, doesn't work without being a MonoBehaviour...

Hmm... what are you seeing as Log output vs. the inspector in this situation? Or, more specifically, what value are you logging to test this? At face value, everything seems reasonable unless there's something unclear from the discard-pile's-first-child-transform.