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!");
}
}
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
You may want to wrap the whole script in a preprocessor [hashsymbol]IF UNITY_EDITOR ... [hashsymbol]ENDIF to avoid build errors
– TobychappellNice, 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 ;-)
– dCalle