How to Exit a Unity Game

Exiting a Unity game is not always as straightforward as clicking the 'X' button. If you're new to Unity, you may be wondering how to exit a game properly. In this article, we'll go through all the ways you can exit a Unity game, whether you're playing on PC or mobile.

Using the Escape Key

The quickest way to exit a Unity game is by using the Escape key. This works on both PC and mobile devices. When you press the Escape key, a menu will appear with various options. One of these options will be 'Quit' or 'Exit' - click this to exit the game.

Unity Escape Key

Using the Application Menu

If the Escape key doesn't work, you can try using the application menu. On PC, this is usually accessed by pressing Alt+F4. On Mac, the shortcut is Command+Q. On mobile devices, you may need to swipe from the top or bottom of the screen to access the menu.

Unity Application Menu

Using the Unity Editor

If you're testing a game in the Unity editor, you can exit by clicking the 'Stop' button. This is located in the top left corner of the editor window. Alternatively, you can press the 'Play' button again to stop the game.

Unity Editor Stop Button

Using a Script

If you're a developer, you can use a script to exit the game programmatically. Here's an example of how to do this:


using UnityEngine;
using System.Collections;

public class QuitGame : MonoBehaviour
{
    public void Quit()
    {
        Application.Quit();
    }
}

You can then call the 'Quit' method from a button or other UI element.

Exiting on Mobile Devices

On mobile devices, exiting a Unity game can be a little trickier. Some games may provide an in-game menu with an 'Exit' option. If this is not available, you can try using the application menu as described earlier.

Conclusion

Exiting a Unity game is a simple process once you know how to do it. Whether you're playing on PC or mobile, there are several ways to exit the game. If all else fails, you can always force the game to close using Task Manager or Force Quit.

Related video of How to Exit a Unity Game