How To Make An OdinEditorWindow

By inheriting from OdinEditorWindow instead of EditorWindow, you can make Unity editor windows in exactly the same way you make inspectors: by using only attributes.

Protip: You can use the OnInspectorGUI attribute if you wish to mix custom editor IMGUI code together with Odin-drawn editors.

public class SomeWindow : OdinEditorWindow
{
	[MenuItem("My Game/My Window")]
	private static void OpenWindow()
    {
        GetWindow<SomeWindow>().Show();
    }
	
    [PropertyOrder(-10)]
    [HorizontalGroup]
    [Button(ButtonSizes.Large)]
    public void SomeButton1() { }

    [HorizontalGroup]
    [Button(ButtonSizes.Large)]
    public void SomeButton2() { }

    [HorizontalGroup]
    [Button(ButtonSizes.Large)]
    public void SomeButton3() { }

    [HorizontalGroup]
    [Button(ButtonSizes.Large), GUIColor(0, 1, 0)]
    public void SomeButton4() { }

    [HorizontalGroup]
    [Button(ButtonSizes.Large), GUIColor(1, 0.5f, 0)]
    public void SomeButton5() { }

    [TableList]
    public List<SomeType> SomeTableData;
}

public class SomeType
{
    [TableColumnWidth(50)]
    public bool Toggle;

    [AssetsOnly]
    public GameObject SomePrefab;

    public string Message;

    [TableColumnWidth(160)]
    [HorizontalGroup("Actions")]
    public void Test1() { }

    [HorizontalGroup("Actions")]
    public void Test2() { }
}

You should not override the OnGUI method in OdinEditorWindows. Instead, if you want to inject custom GUI code, then you override either the DrawEditors method or you can use the OnInspectorGUI attribute on a custom GUI method.

If you do have to override the OnGUI method for some reason, then make sure to call base.OnGUI(). Without this, none of the Odin magic will work and you're basically left with an ordinary EditorWindow instead.