Cancels quitting the application. This is useful for showing a splash screen at the end of a game.
This function only works in the player and does nothing in the web player or editor. IMPORTANT: This function has no effect on iPhone. Application can not prevent termination under iPhone OS.
using UnityEngine; using System.Collections;
public class ExampleClass : MonoBehaviour { public float showSplashTimeout = 2.0F; private bool allowQuitting = false; void Awake() { DontDestroyOnLoad(.gameObject); } void OnApplicationQuit() { if (Application.loadedLevelName.ToLower() != "finalsplash") StartCoroutine("DelayedQuit"); if (!allowQuitting) Application.CancelQuit(); } IEnumerator DelayedQuit() { Application.LoadLevel("finalsplash"); yield return new WaitForSeconds(showSplashTimeout); allowQuitting = true; Application.Quit(); } }