Custom editor window stopped showing up

Greetings.

Yesterday I created a custom window for the editor that featured literally one button. Here’s the code (obviously edited for brevity):

public class CubeSpawner : EditorWindow
{

   [MenuItem ("Window/CubeSpawner")]

   static void Create() {
    // ... does some stuff...
   }

    public static void  ShowWindow () {
        EditorWindow.GetWindow<CubeSpawner>("CubeSpawner");
    }

    void OnGUI () {

	    if(GUILayout.Button("Generate")) {
		    Create();
	    }

    }

}

It was working, was dockable, and it showed the intended button, up until less than an hour ago, when I took a break, saved my project and closed Unity. I didn’t even restart my PC but, when I reopened Unity, the editor gave me some vague warning regarding layouts, and now this custom window only shows up in the Window tab, but when I click it, instead of a window with the declared button showing up, it just executes the functionality implemented in the Create() function. No dockable tab shows up, and it’s not available under the “Add Tab” dropdown menu.

Has anyone else experienced this?

Currently using 2019.1, if that helps.

You attached the MenuItem attribute to your Create method, not to your ShowWindow method. It should be

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

    static void Create() {
        // ... does some stuff...
    }
    // [ ... ]

Attributes always belong to the thing that follows the attribute. This is true for all kinds of attributes. Attributes can be attached to all sorts of things. For example the In / Out attribute can be attached to method parameters like this

public bool SomeMethod([In, Out] object obj)
{

In case of methods you can think about it this way:

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