Exit Full-Screen Implementation, Unity and C#

Frank Warman
1 min readMay 11, 2021

You may think that exiting games would be a function that comes standard in any game you build, however, this is not the case!

If you have a full screen version of your game and you don’t add an exit functionality, the Player could be trapped in full screen and would have to CTRL+ALT+DELETE to close your game! Very unprofessional.

So this short article is on how to prevent that.

One code to rule them all

Since this new code is handling our Game management, it seems best to fit it in the GameManager script!

In our Update() function, we’ll add the one line of code needed (in an ‘if’ statement).

Application.Quit() is the code your looking for to quit your game!

Now the Player just has to hit the Escape key to exit your game, instead of being trapped in there forever!

In the next article we’ll be giving our Enemies some lasers to make them more dangerous!

--

--

Frank Warman

Audio Engineer turned Unity Game Dev. Will be combining both my skillsets when appropriate, and will be documenting my Unity Dev growth in these Medium Articles