Day 34: The Escape Button is a Feature

Tyler Smallwood
May 25, 2021

--

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!

--

--

Tyler Smallwood
Tyler Smallwood

Written by Tyler Smallwood

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

No responses yet