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 bool _isDraggingUp; private const float MAX_PRESSED_TIME = 0.65f; private const float MIN_PRESSED_TIME = 0.2f; private const float MIN_DRAG_DISTANCE = 10f; private const float MIN_UP_DRAG_DIS = 40f; public delegate void OnLongPressCall(); public delegate void OnPointUpCall(); public delegate void OnStartDrag(); public delegate void OnDraging(); 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 OnDraging _OnDrag; private OnEndDrag _OnEndDrag; private OnUpDrag _OnUpDrag; private OnDragOut _OnDragOut; private OnClick _OnClick; public OnUpDrag UpDrag { get { return _OnUpDrag; } } public OnDragOut DragOut { get { return _OnDragOut; } } public OnPointUpCall PointUp { get { return _OnPointUp; } } //测试代码 private int _count = 0; protected override void Awake() { base.Awake(); m_button = GetComponent