//按返回键退出Application
?
1 2 3 4 |
|
//按两次返回退出程序
float _waitTime = 2f;//前后两次按退出间隔时间
if (_waitTime < 2)
{
GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 30, 200, 60), "再按一次退出");
_waitTime -= Time.deltaTime;
if (_waitTime < 0)
{
_waitTime = 2;
}
if (Input.GetKeyDown(KeyCode.Escape))
{
Application.Quit();
}
}
if (Input.GetKeyUp(KeyCode.Escape) && _waitTime == 2)
{
_waitTime -= Time.deltaTime;
}
时间: 2024-12-17 07:35:43