The Escape Button is a Feature

Tristan Engel
Jun 1, 2021

--

Unity doesn’t have the a way to exit the game by default once you build it. When it’s played in windowed mode you can hit the close window button with the mouse. The problem is when you go full screen there is no button to exit the game. We need to build this functionality in manually.
Add the following code the detect the Escape key getting pressed to exit the game.

if (Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}

This can’t be used in the Editor. You will need to build to use this.

--

--

Tristan Engel
Tristan Engel

Written by Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

No responses yet