Made With Unity | 2D Space Shooter Part 11: Main Menu

Before making some code changes, again, lets go and add a simple Main Menu to our game, it will be a breeze.


Go to the Scenes folder, Right click -> Create -> Scene. Named the new scene MainMenuScene

Since I want the Main Menu scene to have the same background image and settings like in the GameScene I will drag my Background game object, the one inside the [ — ENVIORMENT — ] game object, to the Prefabs folder.


Double click the MainMenuScene, select the MainCamera and change the Clear Flags to Solid Color and select the color black as the Background.

Drag the Background object from the Prefabs folder


Right click on the Hierarchy and create a UI image and name it mainmenu_image. Inside the Image component in the Source Image field I’m going to put a sprite image that it was designed to be use on the main menu.

Going to set the Canvas Scaler to have better control on the sprites.

Added some info to the Rect Transform of the mainmenu_image object


Were adding two buttons, Button — TextMeshPro, one is going to be our Play button and the second one our Quit button.

Inside the button game object there is a Text (TMP) object to change the letters on the button; go to each button and one of the type Play and the other one Quit.


Create a new script inside the Managers folder, named it MainMenuManager and add the script component to the UI. On the MainMenuManager script be sure to add using UnityEngine.SceneManagement on your script.

Line 10 will load the GameScene. To know if the GameScene has the index of 1, we need to go to the Build Settings, add the MainMenu scene by pressing Add Open Scenes and put the GameScene has our second option.

On your GameManager script update the index where we ask permission to Restart the game


Inside the play_button and quit_button there is a Button component that has a On Click() section.

On the play_button object press on the plus, add the UI object on the empty field and following the image below find the public method LoadGameScene()

For the quit_button follow the same steps but select the public method QuitGame()

🎮PART 12 🎮



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rehtse Studio

Rehtse Studio

Game Developer sharing content around Unity, programing and tips and tricks in game dev.