I have an EditorWindow that calls OnEnable() and OnFocus() functions when i hit the button. How do i prevent it from happening?
Specifically, if i have an editor window specified by the code below open than it will print “Focus Gained” in the console immediately after the Play button is hit.
using UnityEditor;
using UnityEngine;
using System.Collections;
public class BoxEdTest : EditorWindow {
[MenuItem ("Box Editor/BoxEd Dev Test")]
public static void ShowWindow () {
EditorWindow.GetWindow (typeof(BoxEdTest));
}
[ExecuteInEditMode]
public void OnFocus() {
SubFunction();
}
[ExecuteInEditMode]
public void SubFunction() {
Debug.Log ("focus gained");
}
public void OnLostFocus() {
Debug.Log ("focus lost");
}
}