- Home /
This question was
closed Apr 15, 2016 at 01:36 PM by
meat5000 for the following reason:
Duplicate Question
Question by
rakuzas · Dec 13, 2015 at 02:44 PM ·
androidbuttonquitdouble-tap
Press Back Button Twice to Quit Game
Hello,
I'm using unity 5.2 , Android Native plugin and run on Android platform..
Currently, I'm able to use script below to quit my game.. But some of my player complained that he always suddenly press back button and quit the game.. So, I notice some of apps press back button twice to quit their apps.. I tried to search some examples but just found some java not unity..
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
I tried to put like this (code below).. The toast message appear.. But its just quit the game without press second back button on my device..
void Update ()
{
utilsPlugin = UtilsPlugin.GetInstance();
utilsPlugin.SetDebug(0);
QuitAndroid ();
}
void QuitAndroid ()
{
if (Input.GetKeyDown (KeyCode.Escape))
utilsPlugin.ShowToastMessage ("Press back again to quit");
Application.Quit ();
TapAgain ();
}
void TapAgain ()
{
if (Input.GetKeyDown(KeyCode.Escape))
Application.Quit();
}
Comment