Day 34: The Escape Button is a Feature

Photo by Yuiizaa September on Unsplash

Objective: Use the Escape key to close game.

If we build a game to the desktop and it’s automatically full screen there would be no way to close the game.

We will need to go into our GameManager Script. In our Game Manager we will need to listen for the Escape key being pressed. We do this by using an If statement, seeing if the input is a certain key.

If we search on how to close the game, we’ll come across something called Application.Quit. This will quit an application but it will be ignored while being tested in the Editor.

We can add it under the If statement.

And that’s it! Now when you ever get stuck in full screen mode you can hit the escape key and it’ll close the game!

--

--

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
Tyler Smallwood

Tyler Smallwood

I am passonate on learning to program and use Unity to become a skillful Unity Developer