Pause menu with quit option

No matter how fun a game is, eventually you will have to take a break, and for that we need a pause menu and a way to quit the game. Let’s now have a look at how to add the pause menu with quit option to the space shooter.

Start by making the UI for the pause menu following steps in this article as well as here.

Open the UIManager script and add a private GameObject for the pause menu. Add a function which will toggle this menu:

Open the GameManager and add a bool to check if game is paused. Add a public function called Pause in which you set the bool to the opposite of what it is currently. Call the TogglePauseMenu function from the Pause function and then if _isPaused is true, set Time.timeScale to 0 to stop all movement. Time.timeScale does not affect UI so the menu will still work:

Also add the public function QuitGame that only call Application.Quit. This function quits the game if it is running as standalone as an app on mobile or computer:

Lastly, set the Resume button to call the Pause function on the GameManager and Quit button to call the QuitGame function:

Good luck!

Indie Game Developer