- Home /
Question by
trenki2 · Dec 31, 2014 at 07:24 PM ·
application.quit
OnApplicationQuit and CancelQuit on Android not working?
I tried out the script from http://docs.unity3d.com/ScriptReference/Application.CancelQuit.html (code below) to load a splash screen on application exit. It somehow does not work on Android. Also a script with only Application.CancelQuit
does not prevent the app from closing. Is this not supported on android or is there something special required?
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public float showSplashTimeout = 2.0F;
private bool allowQuitting = false;
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();
}
}
Comment
$$anonymous$$e too. Is it bug? iOS and UnityEditor was O$$anonymous$$!