Open a scene from the Unity editor menu

Daniel Kirwan
3 min readSep 6, 2024

--

Have you ever wondered how people add their own menu items to the toolbar in the Unity editor? Well, today you will find out how, and how easy it is.

My example is about the title of this article and how to open a different scene from your current one without having to dig through your project and find it.

First I make sure that this script is only run in the Unity Editor. So wrap the whole script in the #if Unity_Editor tag. You end the tag after your last class curly brace }.

So once you have the libraries you need and the if tag added, we can go through how to make the menu item appear.

My class is called SceneShortucts and I will go through the rest now.

  1. I have an Open scene method that will ask you if you want to save your current scene before you open the next one. If you click yes, then it will open the scene that has been passed through to the method.
  1. The string being used to load the scene is an interloped string, by using the $ at the beginning of the “”. This allows you to use curly braces{} to add a variable instead of closing and opening the string “” multiple times. The line finished by making sure that the scene trying to load has the .unity file extension
  2. To create a menuitem all you have to do is use the attribute
    [MenuItem (“What you want to see in the editor/what you want to click on”)]
  3. So in my case, the menu text will say [SCENE LOAD]
  4. Once I click that I will see the options I want to click. Main Menu, New Movement & Gameplay Scene 1

And thats it for this article. If you followed along you will now be able to load a new scene quickly from your menu. The only main issue is that you will need to manually add in any new scenes that you want to load.

--

--