Guest User

AskQuit

a guest
Mar 8th, 2015
207
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. /// <summary>
  4. /// An extra script for this repository: https://github.com/paganini24/UnityAndroidExtraPlugins
  5. /// </summary>
  6. public class AskQuit : MonoBehaviour {
  7.     int count = 0;
  8.    
  9.     void Start ()
  10.        {
  11.           UnityAndroidExtras.instance.Init();
  12.     }
  13.    
  14.    
  15.     void Update () {
  16.         if(Input.GetKeyDown(KeyCode.Escape))
  17.         {
  18.             count++;
  19.             if (count == 1)
  20.                 UnityAndroidExtras.instance.makeToast("Please press back button again to exit", 1);
  21.             else if (count == 2)
  22.                 Application.Quit();
  23.         }
  24.     }
  25. }
RAW Paste Data