Adventures in GameDev with GameDevHQ! Day 36: The Escape button is a feature!
So you’ve published your game and it’s now an executable, but have you given your players a way out? If you didn’t, and your game is full screen, you have taken over the players desktop and will never give it back to them!
Fortunately, there’s an easy fix. Just let the player hit the escape key at any time to quit the game. Unity gives you an easy command to quit the program too.
This command won’t work in your editor because it’s specific to builds. This will effectively shut your game down and close the window its in. Great! This is exactly what we want! Let’s put this in the game manager and give our poor player a way to quit the game when he has work to do!
In your GameManagers Update() method, type this:
And that’s all there is to it!
We’re pretty much done with this series, but I’ve still got a couple weeks worth of articles based on the framework and core programming issues, so stick around!