Creating A Feature That Uses The Escape Button To Exit An Application

When you build your application if you have it set to Fullscreen mode then you leave the player having to manually exit your software using something like the “Task Manager”. To avoid this, you can add the ability to press the “Escape” key to exit the application.

This can be done very easily. Just make a game object that rests in your hierarchy such as a “GameManager” or whatever. This needs to be an object that is never deleted or removed from the game for whatever reason and if all else fails, just use an Empty Game Object.

Add a C# script to the above-mentioned object and just add the following code…

[IMPORTANT NOTE]

This feature will not work in the editor. This means that in order to test this out you will have to build a version of your project.

--

--

--

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create API using Azure Function with Python and Azure Cosmos DB

FlutterVita : Gunshots App

Extending Firebase with Cloud functions & ElasticSearch

Solstarter | Community Update 1

Polymer+Node+K8s = All Kinds of Awesome

Testing Applications with JUnit5 and EasyMock. Part 1

How to Create Infrastructure as Code for AWS and Azure

Laziness I: Meta-programming

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adam Reed

Adam Reed

Hi, my name is Adam Reed and I am a software engineer specializing in Unity and C# development. Feel free to scroll through and check out some of my work!

More from Medium

Begin your C# Game Development Journey Using This Challenge

Play a Random Voice-Line in Unity, with just 1 Line of Code

Devlog 28: Added A Charged Shot To My Game

Unity Dev Blog: Creating Enemy Explosions (and triggering them in code)