VIDEO: How to EXIT the GAME with BUTTON in UNITY


Video Description

In this video we see how to make an exit button in Unity, the idea is create a system to quit game by pressing a button from the user interface. This video is a remake which includes a way to quit the application even if you are in the Unity Editor, in the old video, when the button was pressed in the game mode nothing happened, with this new code we also exit the game mode which allows us to test the function without the need to compile.

//This is the begin of the “Exit Game” function that calls the button
//Copy and paste into some control script of yours
//be sure your script is present in the hierarchy
/// Adapt the content of this video to your needs
public void ExitGame()
{
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
//End of the “Exit Game” method

Exit mobile version
Secured By miniOrange