Application.Quit — Exiting the Application

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?




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why should we prefer Django ORM rather than SQL/MySQL

Deliberately creating chaos

Reverse Image Search with Google Cloud


Chrome on Android adds Follow button for RSS feeds

Chrome on Android adds Follow button for RSS feeds

Serve private static content from S3 with CloudFront and Origin Access Identity

Thinking Out Loud: Handling WFH and Hybrid-work

Docker storage drivers and storage models

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
GameDev Dustin

GameDev Dustin

More from Medium

Creating a “negative” powerup

Set Up & Trigger A Timeline Sequence In Unity

Tessellation of Unity Materials

What is a Control Track in Timeline