Int escapeTimes=0;
Void the Update ()
{
If (Input. GetKey (KeyCode. Escape))
{
EscapeTimes++;
The Debug Log (" escapeTimes=================="+ escapeTimes);
If (escapeTimes & gt; 1)
{
Application. The Quit ();
}
}
}
But the real machine, ordered a return key, then directly out of the,,
Log the following
02-04 12:08:37. 360: I/Unity (32715) : escapeTimes==================1
02-04 12:08:37. 360: I/Unity (32715) : UnityEngine. Debug: Internal_Log (Int32, String, Object)
02-04 12:08:37. 360: I/Unity (32715) : UnityEngine. Debug: Log (Object)
02-04 12:08:37. 360: I/Unity (32715) : BgManager: the Update () (at F: \ betaPrj/Assets/Script \ BgManager cs: 436)
02-04 12:08:37. 360: I/Unity (32715) :
02-04 12:08:37. 360: I/Unity (32715) : (Filename: F Line: 0)
02-04 12:08:37. 410: I/Unity (32715) : onPause
02-04 12:08:37. 410: V/AudioTrack (32715) : stop 0 x5b319800
02-04 12:08:37. 410: V/AudioTrack (32715) : stop 0 x5b319800
02-04 12:08:37. 410: V/AudioTrack (32715) : stop 0 x5b319800
02-04 12:08:37. 410: V/AudioTrack (32715) : stop 0 x5b319800
02-04 12:08:37. 860: D/Unity (32715) : ASensorManager_destroyEventQueue returned 0
02-04 12:08:37. 880: I/Unity (32715) : windowFocusChanged: false
02-04 12:08:37. 970: D/Unity (32715) : [EGL] Attaching window 0 x0
02-04 12:08:37. 980: I/gralloc. Sc8830 (32715) : ION_IOC_FREE success dc28b740, phy addr=9 fce7000
02-04 12:08:38. 360: I/Unity (32715) : onDestroy
02-04 12:08:38. 380: D/dalvikvm (32715) : Unregistering JNI method Lcom/unity3d/player/UnityPlayer; NativeVideoFrameCallback: VILII
For this is a question of where is...
CodePudding user response:
EscapeTimes++;This isn't equal to
EscapeTimes=escapeTimes + 1;
As long as the trigger twice your application to exit, the update seemingly will perform many times a second,
CodePudding user response:
02-04 12:08:37. 410: I/Unity (32715) : onPauseLook program was the background
CodePudding user response:
Is the update engine frame in accordance with the function, when you click on the screen from time to tome retention time with the hand, in this time the update function will be executed multiple times;You can use a KeyDown to test
CodePudding user response:
GetKeyDownCodePudding user response:
Upstairs several is wrong, the real reason is not code problems are not unity,In the android system for safety guarantee, key press will directly back to the desktop, and in the middle of the IOS, key procedures are not legally binding
Low version of the android home button may be able to control, high version has to security fixes the problem,
You can try to write OnApplicationPause to capture user press the button to return to the desktop information,