Get Out!

The Escape Button is a Feature

Welcome back! Today we’re going to talk about a simple but important feature. Being able to close out of our game using the Escape key. By default, our game doesn’t know that pressing the escape key should exit our game and if we are running in Full Screen mode this can lead to an issue. To accomplish our goal we want to use a method that Unity provides for us that allows us to exit the running game.

Application.Quit()
Application.Quit()
Using the old Unity Input Manager
Using the old Unity Input Manager
Input Actions Screen
Input Actions Screen
Add new methods from IUIActions Interface
Add new methods from IUIActions Interface
OnExitGame Callback Method
OnExitGame Callback Method
Add Callback Method to Player Actions Component
Add Callback Method to Player Actions Component

Next Time!

That’s it! We’ve added the ability to hit the escape key and exit our application! Next time we will start to look at enhancements I’ll be making as part of the certification portion of the course work that I’m building this game for. If you enjoyed this article, or want to come along with me as I progress on my journey, follow me at gamedevchris.medium.com.

Unity Game Developer, Software Engineer, Gamer, Musician, and Father. Christopher is a creative that enjoys a challenge and loves coding.