using System; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; [RequireComponent(typeof(Button))] public class UIButtonEx: Button { private Button m_button; private enum DragState { None, Dragging, End } private bool _isPressed; private float _pressedTime; private bool _isCalled = false; private bool _isLongPressing; private bool _upDragCalled; private bool _outDragCalled; private DragState _curDragState; private Vector2 _mousePos; private Vector2 _lastFrameMousePos; private Vector2 _startDragPos; private const float MAX_PRESSED_TIME = 0.65f; private const float MIN_PRESSED_TIME = 0.2f; private const float MIN_DRAG_DISTANCE = 1f; private const float MIN_UP_DRAG_DIS = 40f; public delegate void OnLongPressCall(); public delegate void OnPointUpCall(); public delegate void OnStartDrag(); public delegate void OnDrag(); public delegate void OnEndDrag(); public delegate void OnUpDrag(); //向上拖动 public delegate void OnDragOut(); //向外拖动 public delegate void OnClick(); private OnLongPressCall _OnLongPress; private OnPointUpCall _OnPointUp; //长按后抬起 private OnStartDrag _OnStartDrag; private OnDrag _OnDrag; private OnEndDrag _OnEndDrag; private OnUpDrag _OnUpDrag; private OnDragOut _OnDragOut; private OnClick _OnClick; //测试代码 private int _count = 0; private void Awake() { m_button = GetComponent