EditorWindow.GetWindow() Making Multiple Windows When Docked

Hi,

The EditorWindow.GetWindow() method is spawning multiple windows even though the documentation expresses that will not happen. Is there something special I need to know about this function?

_* It appears to only do this when the window is docked.

Any help is appreciated.

Even though this response is years late, I guess it could be useful for the community. (I was searching for that just now)

I had the same problem, in my case I solved by removing a static reference to my Custom EditorWindow.

I was making a confusion between the static instance and other “normal” instances.

The only static method that is left is the one that loads up the Window public static void ShowWindow()

Instead of doing this:

public class MyCustomEditorWindow : EditorWindow
{    
    static EditorWindow window;

[MenuItem("Window/MyCustomEditorWindow")]
    public static void ShowWindow()
    {
              window = EditorWindow.GetWindow<EnvironmentToggleWindow>();        
    }
}

I did that:

public class MyCustomEditorWindow : EditorWindow
{ 
     [MenuItem("Window/MyCustomEditorWindow")]
     public static void ShowWindow()
     {
             EditorWindow.GetWindow<EnvironmentToggleWindow>();        
     }
 
     void OnGui()
    {
        // The 'this' keyword is not needed here, is just to emphasize that we are dealing with the local instance, not an static instance.
        this.titleContent.text = "DEVELOPMENT";
        this.titleContent.image = yellowIconTexture
    }
}