using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.Events;
|
using UnityEngine.EventSystems;
|
namespace vnxbqy.UI
|
{
|
public class TreasureUIEvent : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler
|
{
|
public event UnityAction onClick;
|
|
[SerializeField] Vector2 delta = Vector2.zero;
|
|
Vector2 start = Vector2.zero;
|
Vector2 end = Vector2.zero;
|
public void OnPointerDown(PointerEventData eventData)
|
{
|
start = eventData.position;
|
}
|
|
public void OnPointerUp(PointerEventData eventData)
|
{
|
end = eventData.position;
|
}
|
|
public void OnPointerClick(PointerEventData eventData)
|
{
|
if (!delta.Equals(Vector2.zero))
|
{
|
var _delta = end - start;
|
if (Mathf.Abs(_delta.x) > Mathf.Abs(delta.x))
|
{
|
return;
|
}
|
if (Mathf.Abs(_delta.y) > Mathf.Abs(delta.y))
|
{
|
return;
|
}
|
}
|
if (onClick != null)
|
{
|
onClick();
|
}
|
}
|
}
|
}
|