How to make a Unity Editor Window (with example code)

Ricardo Valério
2 min readDec 13, 2019

--

I also got a YouTube channel, with weekly updates: https://www.youtube.com/channel/UCyOt8sPTqNxRseUzpzUEQQg

In the course of developing my MMORPG project, I had to create tools to create and edit data like spells, quests and NPCs. While it could be an external tool, doing it inside Unity was a much faster way to get the results I needed. In following posts, I will go through the process of creating a simple editor to edit quests.

Here how one of my editors looks like:

You can see it in action in an older version of it here:

But first things first, and that is the very essential of it all: how to make a simple Unity Editor Window.

So straight into action, here’s the snippet of code you need.

This script needs to be inside a folder called “Editor”. It doesn’t matter where it is, as long as it is somewhere inside Assets, for example Assets/Editor, Assets/Scripts/Editor, and so on — this makes it possible to also publish assets with their own editors nicely packed up inside their own asset folders.

How to create a Unity Editor Window, breaking it down:

  • Extend EditorWindow
  • Define where the menu will be placed with the MenuItem Attribute in a publicly available static method that can…
  • Instantiate the window with GetWindow
  • Layout your UI in OnGUI

That’s it. If you now go to Unity, the menu entry should be there, and you can now open your Unity Editor Window. You can also move it around and place it as a tab, for convenience.

On the next part, we’ll add some logic to layout items in a Master/Detail view, to list items and edit them.

Let me know your thoughts.

Update: I have created a Patreon page, where you can support my work. You can check it out at https://www.patreon.com/rv_gamedev

Take a look at my project, and if you would like to follow the development, hit Subscribe and the alert icon.

https://www.youtube.com/channel/UCyOt8sPTqNxRseUzpzUEQQg

--

--

No responses yet