Unity: Creating a Main Menu
The first impression also counts in games!
Every single game I played so far featured a Main Menu. Even if it just was a simple one where you just could press either “Play” or “Quit”. Menus are the very first things the player will see. Therefore, you should also consider to design the menu in a good way to represent the feeling of your game. Let’s get started with the Main Menu for the Space Shooter!
Creating a new scene
Usually, the Main Menu is stored in another scene. When the player wants to start a game, Unity will simply load another scene. Depending on the game or scene size, the player might or might not notice a loading delay. If the delay will be very long, the player will usually see a loading screen or sequence. The Space Shooter is a rather small game and therefore, loading the other scene should happen pretty quickly, independent from the hardware the player has.
To get started in actually creating the Main Menu, we need to create a new scene.
- Right click the Scenes folder in the Project window > Create > Scene
- Name the scene MainMenu to be able to distinguish the two scenes we have
Loading the new scene
After creating the new scene, we have to load the scene to be able to edit the content in it. Simply double-click the new scene and it will open up. If you have not saved your scene before, you will be asked to save your changes.
If you open the scene, you will se a pretty empty Game view and Hierarchy. Because this is a completely new blank scene, you also have the bare minimum of GameObjects. Remember how we started the Space Shooter? We also started with a blank scene like this.
Adding the contents of the Main Menu
I. Game title image
A Main Menu only lives with content in it. Normally, a Main Menu always contains the name of the game in some way. Let’s do the same for the Space Shooter!
- Add an Image component
- Assign a Target Image
- Make sure to Preserve the Aspect Ratio
- Adjust the size of the image to your liking
To avoid any issues because the target resolution might be different from yours, remember to set the Canvas Scaling Mode to “Scale with Screen Size”!
II. UI Buttons
We should add some buttons for the player to start the game. Doing so is as easy as adding an Image:
- Right-click the Canvas > UI > Button
- Expand the component to change the shown text inside the button
- Re-Position the button to your liking
If you have found some assets or want to play around with the settings of the Button component for a better look-and-feel for the game you create, you’re free to do so. It’s your game. Make it special!
Your finished Main Menu could look like mine:
There we go! We just created a Main Menu and added another important part of every game!