The Escape Button is a Feature

Objective: Exit game when user presses the escape key

I’m gonna add a feature to exit the game when the player presses the escape key. In order to do that I add the following code in the GameManager script within the Update function.

If you want to quit the game from the unity editor, you have to uncomment the line UnityEditor.EditorApplication.isPlaying = false.

And that’s all! You can exit game using the escape key.

--

--

--

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

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

Recommended from Medium

iOS 14 — The standout features you need to know about

‘Hello world!’ in Swift, Enterprise Edition

Say Hello to Widgets With iOS14

DRY String Localization with Interface Builder

Tips for testing your iOS app’s accessibility

Accessibility Shortcuts menu with Smart Invert, Switch Control, Voice Control and VoiceOver options on it.

CryptoKit tutorial. How to use CryptoKit on iOS13 apps

Writing an iOS Shortcut to Track Inhaler Usage

iOS 15 Navigation bar appearance changes issue

This is sample screen shot of UINavigation Controller.

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
Rusben Guzman

Rusben Guzman

A Software Engineer passionate about game dev and interactive products with Unity. I consider video games to be the artistic expression of programming.

More from Medium

Depth with Unity TileMaps

Introduction To Variables in C# For Unity

Quick tip — Enabling post-processing in Unity Universal Render Pipeline

Variables