How to create EditorWindow on game load


I am trying to create a custom EditorWindow at the start of the game. I want the window to be created without having the user to select if from the ‘window’ menu.

I figured out I should use [InitializeOnLoad] -, and create the window in the static constructor.

Here is my code:

using UnityEngine;
using UnityEditor;

public class SupportScript : EditorWindow {
	static EditorWindow window;
	static SupportScript()
		window = ScriptableObject.CreateInstance(typeof(SupportScript) ) as EditorWindow;

            Debug.Log("Window showed");

    void OnGUI()


When I launch the game, I get bunch of errors such as:

  • Instance of ContainerWindow couldn’t be created because there is no script with that name.

  • System.NullReferenceException: Object reference not set to an instance of an object

  • Failed to destroy editor windows: #1

The first error is in the line: Window.Show();

But, if I am changing something in the script (or any other script) and so the scripts recompile, everything works fine. So the problem is only on the first launch.

Does any one know any other method to create a window on editor launch? I would appreciate any kind of help in this issue.

Many thanks in advance,


Simply use the update delegate (shown here) as a one-time-trigger. That should delay the creation until the editor runs it’s first update.

Something like this:

class StartupHelper
    static StartupHelper()
        EditorApplication.update += Startup;
    static void Startup()
        EditorApplication.update -= Startup;
        // Do your stuff here,