Skip to content

Instantly share code, notes, and snippets.

@ShutovKS
Last active May 15, 2024 19:19
Show Gist options
  • Save ShutovKS/5b8598672309d116710bddda51b2d297 to your computer and use it in GitHub Desktop.
Save ShutovKS/5b8598672309d116710bddda51b2d297 to your computer and use it in GitHub Desktop.
Quitting the game in Unity
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