x


How to check if an EditorWindow is opened

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.

more ▼

asked Apr 26 '12 at 06:38 AM

sedlu gravatar image

sedlu
16 1 6 8

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x169
x94
x93

asked: Apr 26 '12 at 06:38 AM

Seen: 397 times

Last Updated: Apr 26 '12 at 06:38 AM