/// <summary> /// Triggers the bound pointer up action /// </summary> public virtual void OnPointerUp(PointerEventData data) { if (Time.frameCount == _lastPointerUpAt) { return; } _destination = Input.mousePosition; _deltaSwipe = _destination - _firstTouchPosition; _length = _deltaSwipe.magnitude; // if the swipe has been long enough if (_length > MinimalSwipeLength) { _angle = MMMaths.AngleBetween(_deltaSwipe, Vector2.right); _swipeDirection = AngleToSwipeDirection(_angle); _swipeEndedAt = Time.unscaledTime; Swipe(); } // if it's just a press if (_deltaSwipe.magnitude < MaximumPressLength) { Press(); } _lastPointerUpAt = Time.frameCount; }
/// <summary> /// Initializes a new instance of the <see cref="MoreMountains.Tools.MMSwipeEvent"/> struct. /// </summary> /// <param name="direction">Direction.</param> /// <param name="angle">Angle.</param> /// <param name="length">Length.</param> /// <param name="origin">Origin.</param> /// <param name="destination">Destination.</param> public MMSwipeEvent(MMPossibleSwipeDirections direction, float angle, float length, Vector2 origin, Vector2 destination) { SwipeDirection = direction; SwipeAngle = angle; SwipeLength = length; SwipeOrigin = origin; SwipeDestination = destination; }
public static void Trigger(MMPossibleSwipeDirections direction, float angle, float length, Vector2 origin, Vector2 destination) { e.SwipeDirection = direction; e.SwipeAngle = angle; e.SwipeLength = length; e.SwipeOrigin = origin; e.SwipeDestination = destination; MMEventManager.TriggerEvent(e); }
/// <summary> /// Triggers the bound pointer up action /// </summary> public virtual void OnPointerUp(PointerEventData data) { _destination = Input.mousePosition; _deltaSwipe = _destination - _firstTouchPosition; _length = _deltaSwipe.magnitude; // if the swipe has been long enough if (_length > MinimalSwipeLength) { _angle = MMMaths.AngleBetween(_deltaSwipe, Vector2.right); _swipeDirection = AngleToSwipeDirection(_angle); Swipe(); } // if it's just a press if (_deltaSwipe.magnitude < MaximumPressLength) { Press(); } }