Creating a Main Menu with Unity UI

Let’s make a simple Main Menu suitable for any game!

Add a Canvas and Panel to start:

When you have no Canvas in the scene, creating any UI element will automatically create a Canvas for you!

Rename and set an image (sprite) for the background (the panel):

Rename, set to no transparency, and choose a sprite image

You may want to change what the Main Camera displays in the background:

Sets the camera background to black, instead of showing the skybox (Only shows these changes in the Game window)

Add some buttons:

I always recommend installing Unity’s TextMeshPro package and using the UI variants from that. The quality is much better.

Rename and change the text:

Add a title image or text:

Set the image, move the menu elements, and scale the image up:

Elements lower in the Canvas Hierarchy will be displayed on top of higher elements
I always like to make the Highlighted and Pressed colors a bit darker, since I think they are too light by default

Let’s see the result so far!

Now let’s make the buttons functional:

Create a main menu script and add it to a GameObject in the scene

Now in Visual Studio (or equivalent), write the code for the functions:

Make sure the parameter in LoadScene( ) is either the exact scene name (string) or the correct scene build index (int)

Now connect the buttons to the code from the Inspector:

Add an OnClick event to both buttons, set the object with your script, and select the 2 functions

Lastly, set the canvas to fit the screen, regardless of resolution:

Choose your indended resolution to reference for scaling

If Canvas elements are moving weirdly when you scale the Game window, try this:

Make sure the anchor preset is set to the correct position for each Canvas element. Choose the preset based on which part of the screen the element should be positioned relative to. Alt-Click to snap to that position.

Now the simple Main Menu is finished! Start and Quit buttons work!

Unity game developer / C# Programmer / Gamer