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

Gotta monitor'em all! — Part 2

Thompson Write-up [TryHackMe]

New MacBook Pro 13-inch 2018 Model still affected by Thermal Throttling Issue during CPU or GPU…

Enhance Your IT Asset Management With Custom Substates In AssetSonar

Sunlight is the Best Disinfectant: The Value of Code “Fingerprints”

CS373 Fall 2020: Week 7

Dear summoners: We will perform non-stop updates on 2022/1/6 (Singapore time).

Role Based App Navigation using BLoC Pattern

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

Audio effects for Enemies

Doing basic unit testing in Unity/C#

Journal 140 — Unity Project Development Part 2–2.5D Shooter

Variables! — The building blocks of programming