Last active
May 15, 2024 19:19
-
-
Save ShutovKS/5b8598672309d116710bddda51b2d297 to your computer and use it in GitHub Desktop.
Quitting the game in Unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class ExampleQuit | |
{ | |
public static void Quit() | |
{ | |
#if UNITY_EDITOR | |
UnityEditor.EditorApplication.isPlaying = false; | |
#elif UNITY_WEBGL | |
// Link to the website page where you want to go after clicking the exit button | |
const string WEBPLAYER_QUIT_URL = "http://your-address.com"; | |
UnityEngine.Application.OpenURL(WEBPLAYER_QUIT_URL); | |
#else | |
UnityEngine.Application.Quit(); | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment