移动端单双击检测
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CSTest : MonoBehaviour {
private int t = 1;private bool state = false;
void Update () {
if (Input.touchCount > 0)
{
if (Input.touches[0].phase == TouchPhase.Began)
{
if (!state)
{
StartCoroutine(CountDown());
state = true;
}
t++;
}
}
}
IEnumerator CountDown()
{
yield return new WaitForSeconds(0.2f);
if (t == 2)
{
Debug.Log("单击");
}
else
{
Debug.Log("双击");
}
t = 1;
state = false;
}
}
本文标题:移动端单双击检测
本文链接:https://www.haomeiwen.com/subject/nkltiftx.html
网友评论