Hi, I wrote a custom editor and tried to call its initialization function when the user press Play in UnityEditor.
[InitializeOnLoad]
public class EditorEntry : Object
{
static public GameObject obj;
static public bool isStart = false;
static EditorEntry()
{
Debug.Log("EditorEntry!");
SceneManager.Singleton.Initialize();
EditorApplication.playmodeStateChanged += Destroy;
}
static void Destroy()
{
if(!EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode) //before start
{
}
else if(EditorApplication.isPlaying && EditorApplication.isPlayingOrWillChangePlaymode) //start to play
{
EditorWindow.GetWindow<ActionEditor>().Initialize();
//SceneManager.Singleton.LoadScene(Path.GetFileNameWithoutExtension(EditorApplication.currentScene));
}
else if(!EditorApplication.isPlaying && !EditorApplication.isPlayingOrWillChangePlaymode) //after stop
{
}
}
}
However, because of the implementation of ActionEditor.Initialize(), if the user doesn't open the ActionEditor, then calling Initialize() will cause some errors. Therefore, I would like to know is there any way to check if an EditorWindow is opened?
Thanks.
asked
Apr 26 '12 at 06:38 AM
sedlu
16
●
1
●
6
●
8