How to Create a Start Menu in Unity

You can access the full course here: CREATE YOUR FIRST 3D GAME IN UNITY

Welcome to this beginner-friendly tutorial where we will guide you through setting up a basic Unity menu for your game. Your game’s main menu is not only the first impression players have of your game, but it also plays a vital role in navigation. In this tutorial, we will walk you through creating a simple but professional-looking Unity menu, including various buttons like ‘Play’ and ‘Quit’ in a game scene.

So without further ado, let’s get started!


The tutorial assumes you have some familiarity with C# programming and using Unity Editor.

If you need help, the Unity Game Development Mini-Degree offers an extensive collection of courses from the basics to game mechanics, procedural maps and even optimizing Unity menu. This Mini-Degree has been recognized as an invaluable resource for not just game development, but an array of non-game industries, perfecting Unity skills and opening doors to unlimited opportunities.

CTA Small Image

Unity Menu – Part 1

In this lesson, we’ll set up the Unity Menu for our game.

The Unity Menu Scene

This Unity Menu will be a separate scene. Let’s create a new scene called Menu in the Scenes folder now.

Scenes folder

Then, we’ll double-click on the Menu asset to open the Menu scene. You’ll see a default empty scene in your Editor.

Menu scene

First, we’ll change the background we have:

  • Select the Main Camera object
  • Go to the Camera component in the Inspector window
  • Set the Clear Flags property to the Solid Color option. This way, the camera will render color as a background
  • Set the Background property to a nice green color. This will be the background color of the scene

scene background

Now you should have the green background in the Game view.

Game view

Then, we’ll create a new Canvas object in the Hierarchy, as we did earlier.

Canvas object

The Title Text

Now, let’s create a title text for our game:

  • Create a new TextMeshPro object as a child of the Canvas
  • Name it TitleText
  • Position it above the center of the Canvas

Title Text


Then, we’ll configure the TitleText > TextMeshPro component in the Inspector window the following way:

  • Set the Text to “My 3D Game
  • Enable the Bold Font Style
  • Make the Font Size bigger. We’ll go with 60
  • Set the Alignment to Center-Middle

TextMeshPro component

Here’s how your title should look like in the Game view:

Game view

The Unity Menu Buttons

Next, we’ll create a button that will start the game:

  • Right-click in the Hierarchy and select the UI > Button – TextMeshPro option from the context menu
  • Name that button PlayButton
  • Make the PlayButton about the same size as the TitleText
  • Position the PlayButton in the middle of the Canvas


PlayButton in Canvas

Then, let’s select the child Text object of the PlayButton, go to the Inspector, and set the TextMeshPro > Text to “Play“.

TextMeshPro Inspector

Game View

Next, we’ll create a button to quit our game:

  • Duplicate the PlayButton by selecting it and pressing the Ctrl+D hotkey
  • Rename the duplicate to QuitButton
  • Move QuitButton to be below the PlayButton
  • Change the text on the QuitButton to “Quit

Quit Button as seen in the Unity Hierarchy

Menu screen with Play and Quiz buttons present

You can start this scene and click on the buttons, but nothing will happen right now, as we have to set those buttons up.

The Unity Menu Script

Let’s create a script to control those buttons:

  • Create a new C# script called Menu in the Scripts folder
  • Attach this Menu script to the Canvas object

Menu Script

Then, we’ll open the Menu script and do the following:

  • Remove the Start and Update functions, as we won’t need them
  • Add the SceneManagement library so we could load the scenes from this script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement; // Add me!!

public class Menu : MonoBehaviour


Our UI buttons can call functions from the scripts. So, we’ll create the functions that those buttons will call. Let’s start with a function for the Play button:

  • Create a new public function called OnPlayButton
  • In that function, make the Scene Manager load a scene with an index of 1. This will be our Level 1 
public void OnPlayButton ()

Next, we’ll create a function for the Quit button:

  • Create a new public function called OnQuitButton
  • In that function, call the Application.Quit function to make the game close
public void OnQuitButton ()

Here’s what the full Menu script looks like:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class Menu : MonoBehaviour
    // Called when we click the "Play" button.
    public void OnPlayButton ()

    // Called when we click the "Quit" button.
    public void OnQuitButton ()

Updating The Scene

Now, let’s get back to the Unity Menu scene in Unity Editor. We have to connect our buttons to the Menu script now.

We’ll set up the PlayButton first:

  • Select the PlayButton and go to the Inspector
  • There is a menu for the On Click event at the bottom of the Button component
  • Click on a plus icon there to add a new entry
  • Drag the Canvas object to the object field of that entry
  • Select the Menu > OnPlayButton function in the function field

Now, when you click on the Play button, this button will call the Menu.OnPlayButton function.

Menu.OnPlayButton function

Before testing this Play button, we have to add the Menu scene to the Build Settings:

  • Press the Ctrl+Shift+B hotkey to open the Build Settings window
  • Press the Add Open Scenes button to add the Menu scene to the list
  • Drag the Menu scene to the top of this list

Build Settings

If you start the game and click the Play button now, it will take you to the Level 1.

Play button

Level 1

The Quit Button Challenge

As a bit of a challenge, we want you to connect the Quit button to the Menu script by yourself.

In this lesson, we created the Unity Menu and made it start the first level. In the next section, we’ll finish our work on the Menu.

Unity Menu – Part 2

In this lesson, we’ll connect the Quit button to the Menu script.

The Quit Button Challenge Implementation

Here’s what you need to do to connect the Quit button to the Menu class:

  • Select the QuitButton game object
  • Go to the Button component in the Inspector
  • Add a new entry to the On Click event listener
  • Drag the Canvas object to the object field of that entry
  • Select the Menu > OnQuitButton as a function of that entry

Inspector with the QuitButton function in On Click

If you start the game and try to press the Quit button, nothing will actually happen. That’s because the Application > Quit function works only in the built project, and doesn’t work in Editor.

Game screen with final menu

Unity Menu Wrap-Up

And that’s a wrap! Congratulations on setting up your Unity menu. Not only will this main menu help your players navigate your game effortlessly, but it also gives a polished, professional look to your work. We were able to implement the ‘Play’ and ‘Quit’ buttons and tie them to respective actions in the game. The skills you learned in this tutorial can easily be transferred to more complex games, allowing you to design menus that fit your unique needs. We encourage you to experiment with different styles and designs to truly make your Unity menu stand out. Happy gaming!

If you want to gain more Unity and game development skills, it’s worth noting the comprehensive learning provided by the Unity Game Development Mini-Degree. This Mini-Degree encompasses not just creating static menus but a lot more, including the development of both 2D and 3D games, procedural maps, animation, and even mastering Unity menus. With Unity powering more than half the global games, this Mini-Degree is an invaluable resource for both beginners and seasoned developers looking to expand their game creation capabilities.

Did you come across any errors in this tutorial? Please let us know by completing this form and we’ll look into it!

Python Blog Image

FINAL DAYS: Unlock coding courses in Unity, Godot, Unreal, Python and more.

Transcript – Unity Menu – Part 1

Welcome back everyone. In this lesson we are gonna be looking at setting up our main Unity menu. So this is gonna be in a brand new scene.

So let’s go down to our scenes folder right here and I’m gonna right click and go create scene. And I’m just gonna call this one, menu. Okay?

We then wanna double click on this to open it up. Yes, we’ll save the scene we’re currently in. And here we are in a brand new scene.

Now the first thing we’re gonna do is make it so that the background, if we go over to our game view here, isn’t the sky box, okay? We’re gonna make it a nice flat color. So let’s select our main camera game object.

And in the inspector, let’s change the clear flags from Sky Box to solid color. This basically means that if there is no object in the way it’s just gonna render a background color.

And we can of course change that by changing the background color property right here. And I’m just gonna make this a nice green, something like this perhaps. Okay?

And then what we can do is we can go ahead and create our canvas, which is gonna hold our UI elements. So I’m gonna right click and go UI canvas. That’s gonna create a new canvas and an event system.

And then on our canvas we are gonna have three different UI elements. We’re gonna have some text for basically the name of the game and two buttons, one that is for playing the game and one for that.

And one we press when we want to quit. Okay, so I’m gonna right click on Canvas, I’m gonna go UI, text-text Mesh Pro. Let’s call this one, title text. We can hop over into our scene view.

And if you’re not in this view that I’m right now you just wanna click on the 2D button at the top right corner of the scene view and then select the text or select your canvas and press F to focus in on it.

So for our title, I’m gonna position it just above the center like so and I’m gonna make it bold, font size, we can keep it at about 36 and let’s just center the alignment as well.

And I’m gonna call this one, My 3D Game. There we go. Okay, now next up we need two buttons. One to play the game and one to quit the game.

Now for buttons, we can right click on canvas go down to UI, and you’ll see down here we have a long list of different elements.

We could have sliders, scroll bars but you’ll see there is a button-text mesh Pro. Let’s click on that and I’m gonna call this one our play button.

Okay, so now for this button, I’m gonna increase it in size a bit like so, and then I’m going to open it up ’cause as you can see there’s a child object which is the text element.

And I’m gonna rename or I’m gonna change the text to display play. Okay, just like that. So if we look at our game view that’s what it’s gonna look like.

And then for the second button, we can just copy and paste the play button or control D to duplicate it, move it down tiny bit. I’m gonna rename this to our quit button and then change its text to say quit.

Okay, and there we go. So when we press play, we’ll as you can see, if I press play, I’m actually able to click on these buttons. You can see there’s a little color change but they don’t do anything.

So how do we make it so that when we press play it will launch us into our first level and quit will basically quit the game.

Well, for that we are gonna be creating a script. So let’s go to our scripts folder and we’re gonna create a new C sharp script called Menu.

And this menu script, I’m gonna go ahead and attach this to our canvas since I reckon that’s probably gonna be the best place to have it for now attached to the canvas.

And then let’s open it up. Now, inside of the menu script we’re not gonna be needing start or updates. So we can delete those two like so.

And instead we are gonna be adding in using UnityEngine dot SceneManagement because we do wanna be able to switch between scenes.

Now the way that the buttons work is that when you press a button, you can set it up so that it can actually call a function on a given component.

So what we’re gonna do on this menu script which is a component of Canvas, is we’re gonna create a function for pressing the play button and a function for pressing the quit button.

So I’m gonna create a public void and I’m gonna call this one, On Play Button. Now, it is important to note that this function has to be public because we are going to be accessing it from outside of this class.

And when we press the play button, what we want to do is lower it into the first level. So I’m gonna go SceneManager dot LoadScene. And there’s two ways you can do this.

You can of course enter in the name of your level one, okay. But later on you might go ahead and change the name of the level. You know, you might make it level one dot one or whatever.

So instead, I’m just gonna use the build index of one. Now the build index of one is not the first scene, but the second one, okay, zero build index zero is gonna be our Unity menu scene.

And then build index one is gonna be our level one. So we can just enter in the build index like so. And then we have the quit button. So I’m gonna create a public void On Quit Button function right here.

Now what this is gonna do is it is going to quit the application. Okay? So if we have our game window up and we press quit, it’s gonna close down the game.

Now Unity has this already set up for us so all we need to do is go Application dot Quit. Okay? Just like that. And that is gonna close down our game pretty easily.

So yeah, on play button and on quit button, these are the two functions we have created. Now let’s go over and connect those to the buttons.

So back inside of the editor right here, what I’m gonna do is I’m gonna select the play button right here and I’m gonna go down to the inspector.

Now in the inspector you see that we have an image component which basically renders the button background image and then we have a button component and this is basically in charge of detecting when we’re clicking on it and changing the tint for when we’re highlighting, when we’re pressing, et cetera.

And you’ll also see something down here which says on click and it says list is empty. Now this is what is known as an event listener.

We’re not gonna really go into what an event is but basically this is a list that we can attach functions to so that when we press the button those functions are executed.

So what I’m gonna do is click on the little plus down here at the bottom right to add a new item to the list. And I’m gonna drag in the canvas to the object field here.

And then where it says no function, I’m gonna click on that, I’m gonna hover over our Unity menu and then I’m going to select the on play button function right here.

So now when we click the play button, this on click event is gonna basically look at its list of functions and it’s gonna call those. So before we press play and test this out, let’s first of all go to file build settings and add the Unity menu here.

Now to quickly add the scene you currently in, we can just go add open scenes, that’s gonna add the menu to the list but we want Unity menu to be the first scene in the list. So I’m just gonna click and drag it up here.

That is because Unity menu is now building index zero, level one is one, level two is two. We can then close outta this, press play. And then when we have launched into our game let’s press the play button and see what happens.

And you’ll see it takes us over to level one and then we can of course play through this game here. So yeah, that is the play button working. Now as a bit of a challenge, I want you to go ahead and set up the quit button right here.

I want you to connect this up to our on quit button function which of course is our menu script. That is a component of Canvas.

So it works in pretty much the exact same way as we’ve done with the play button but you’re of course choosing a different function. So have a go at that and I’ll be right back to see how you’ve done.

Transcript – Unity Menu – Part 2

All right, so I hope you had a go at the challenge. Pretty much what we want to do is we want to create the On Trigger Enter function right here, okay?

So On Trigger Enter which has the collider as the parameter. And then what we’re gonna do is we’re gonna check, if other.CompareTag is Player.

So if the object that has hit the coin is of type Player then we are going to go, other.GetComponent, oops dot Get Component, PlayerController.AddScore and would send over a value of one for this coin, okay?

And then to destroy the coin we want to go Destroy game Object, okay? With a lowercase G, which references this game object that the script is attached to.

So that is all the code we need for detecting our overlap triggers, and then adding to the player score and then destroying the coin. So let’s save that. Let’s go back into Unity now.

And what we’re gonna do is we are gonna select our coin object, just move it over to a position where we might want it to be. Let’s just say over here, go to our game view, press Play and let’s see if it works.

So as you can see, our coin is spinning around and if I collect it, you’ll see that it disappears. And if we click on our player game object, you’ll see down in our player controller, we have our score property visible and it has a value of one.

Okay, let’s actually go ahead now and select our coin. Let’s go to a prefabs folder. Let’s drag it in there to save it as a prefab. And we can now copy and paste this coin a couple times to see how the score ticks up.

So I’m gonna select our player. I’m gonna press Play and keep an eye on the score property down here at the bottom right, okay?

When I start collecting coins you can see 1, 2, 3, 4, 5, and six, okay? And then of course, if we get hit by the enemy we get tail pulled back to the start and everything has been reset.

So yeah, that is how we can set up coins which then ties into our player’s scoring system. Now in the next lesson, we are going to be looking at actually setting up our level, okay?

We’re gonna be placing our enemies around, we’re gonna be placing our coins, getting the platforms and all that set up, and so that we can start actually getting some levels built, okay? So thanks for watching and I’ll see you all then.

Interested in continuing?  Check out our all-access plan which includes 250+ courses, guided curriculums, new courses monthly, access to expert course mentors, and more! You can also try out our Unity Game Development Mini-Degree to learn not only about Unity menus, but every fundamental you could ask for to build 2D and 3D games.