1.实现单击、双击、长按功能
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
public class ButtonControl_Click_Press_Double : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
{
public float pressDurationTime = 1;
public bool responseOnceByPress = false;
public float doubleClickIntervalTime = 0.5f;
public UnityEvent onDoubleClick;
public UnityEvent onPress;
public UnityEvent onClick;
private bool isDown = false;
private bool isPress = false;
private float downTime = 0;
private float clickIntervalTime = 0;
private int clickTimes = 0;
void Update()
{
if (isDown)
{
if (responseOnceByPress && isPress)
{
return;
}
downTime += Time.deltaTime;
if (downTime > pressDurationTime)
{