Adding A Quit Game Option In Unity

Ben Pielstick
1 min readApr 20, 2021

Unity does almost nothing by default. While some game engines provide a few basic features that the developer can override if desired, Unity makes the developer think of almost everything themself. This can be a good or bad thing, depending on how you look at it, but one of the consequences is that unless you provide some way for the player to quit out of your game in Unity, a way simply won’t exist.

Fortunately like with most things, Unity makes this rather easy. All it takes is one line of code to actually quit your application. Where you put that line of code though is completely up to you. You’ll have to come up with your own menu system, or decide some other way to let players quit your game.

To quit the application, call Application.Quit

One thing to note is that this doesn’t work inside the editor, which unfortunately means that to really test this you’ll have to build your project and run the executable. This isn’t too big of a deal though, since you shouldn’t have to test this too heavily, and once you have it working you can go back to focusing on all the other things you need to add to your game.

--

--

Ben Pielstick

Game developer with over 12 years of experience, mainly focused on MMOs.