| 12345678910111213141516171819202122232425262728293031 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- //持久化的处理脚本,在app启动时就应开始常驻
- public class PersistenHandler : MonoBehaviour
- {
- public static PersistenHandler ins;
- public static void Init() {
- if (ins) return;
- GameObject obj = new GameObject("PersistenHandler");
- ins = obj.AddComponent<PersistenHandler>();
- DontDestroyOnLoad(obj);
- }
- long lastPressExitTime = 0;
- void Update()
- {
- if (Input.GetKeyDown(KeyCode.Escape)) {
- long lastLast = lastPressExitTime;
- lastPressExitTime = JC.CS.Utility.GetTimestamp();
- if (lastPressExitTime - lastLast < 10 * 1000) {
- Application.Quit();
- } else {
- PopupMgr.ins.ShowTip("再按一次退出APP");
- }
- }
- }
- }
|