how we exit of my project with twice pressing back button???
Hi guys, i want to main scene my project with twice pressing back button mobile exit it for in work i use of code Input.GetKey (KeyCode.Escape) but this code with once pressing my project exit. does anyone know a way to give???? Thank you
Answer by aditya · Apr 13, 2016 at 10:19 AM
uint exitCount = 0;
void Update(){
if(Input.GetKeyUp(KeyCode.ESCAPE)){
exitCount++;
if(!isInvoking("disableDoubleClick"))
invoke("disableDoubleClick", 0.3f);
}
if(exitCount == 2){
CancelInvoke("disableDoubleClick");
Application.Quit();
}
}
void disableDoubleClick(){
exitCount = 0;
}
Answer by fffMalzbier · Apr 13, 2016 at 10:21 AM
You can start a small timer that counts the time from one Input.GetKey (KeyCode.Escape) to the next. if the exit key was pressed twice inside your designated time exit the application, if not do not exit.
Your answer
Follow this Question
Related Questions
Unity input not working "up arrow",KeyBoard Up arrow input not working 0 Answers
How to add score to text when button down? 1 Answer
How do I save separate keycodes presses at same time and store for use later in update? 0 Answers
Check any Input.GetAxis from any Joystick 0 Answers
Input script 1 Answer