Unity3D-连续点击两次返回键退出游戏
本文提供全流程,中文翻译。
Chinar坚持将简单的生活方式,带给世人!
(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例)
1
Count Down —— 倒计时
在 Update() 中直接调用 EixtDetection()
using UnityEngine;
///
/// 一个测试倒计时的类
///
public class TestCountDown : MonoBehaviour
{
private bool IsTiming; //是否开始计时
private float CountDown; //倒计时
void Update()
{
EixtDetection(); //调用 退出检测函数
}
///
/// 退出检测
///
private void EixtDetection()
{
if (Input.GetKeyDown(KeyCode.Escape)) //如果按下退出键
{
if (CountDown == 0) //当倒计时时间等于0的时候
{
Count