The Escape Button is a Feature

Objective: Quit the game when the Escape key is pressed.

In the Game Manager script, create a new public method called QuitGame(). Within the QuitGame() method, create an if statement stating that if the Escape key is pressed down, quit the application.

Note: The Application.Quit() command will not execute within the Unity editor. To test the functionality of the Escape key within the Unity Editor, use: UnityEditor.EditorApplication.isPlaying = false;

Next, call the QuitGame() method within the Update() method. Save the script, go back into Unity and create a new build to test the functionality.

--

--