Day 34: The Escape Button is a Feature
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!