Application.Quit — Exiting the Application

GameDev Dustin
2 min readJan 19, 2022

One thing every game needs is the ability to exit.

In windowed mode, a player can hit the X button at the top of the window, but in full screen they have to resort to cntrl+alt+del!

Now, we could implement this as a button our main menu or in the game view, but we are simply going to add it as a when button pressed in our main game view.

We aren’t building this prototype to be a finished released product. We’re doing it to learn how to use Unity and C# for future projects.

So, let’s briefly cover the Application.Quit functionality in Unity.

“Quits the player application.

Shut down the running application.
The Application.Quit call is ignored in the Editor.”

First, let’s make sure the player knows how to quit the game.

In our GameManager script, we add a simple check for Keydown.Escape and use the Application.Quit() call if true.

Click File, Build settings and then the build button to select the folder where your game build will reside.

You should end up with a folder containing files similar to the above screenshot.

Run the Galaxy Shooter 2D (or whatever you named your project) application and give it a try!

Easy, right?