private void SwipeEnd(Vector2 startPos, Vector2 endPos, float timeStartSwipe, int index, bool isMouse) { if (onlyFireWhenLiftCursor) { if (!isMouse) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.touches[i]; if (touch.fingerId == index) { return; } } } else if (mouseIndex.Contains(index) || Time.realtimeSinceStartup - timeStartSwipe > maxSwipeDuration) { return; } } Vector2 dir = endPos - startPos; SwipeInfo sw = new SwipeInfo(startPos, endPos, dir, timeStartSwipe, index, isMouse); IT_Gesture.SwipeEnd(sw); if (!(dir.magnitude < minDistance * IT_Gesture.GetDPIFactor()) && !(Time.time - lastSwipeTime < minDurationBetweenSwipe)) { lastSwipeTime = Time.time; IT_Gesture.Swipe(sw); } }
void SwipeEnd(Vector2 startPos, Vector2 endPos, float timeStartSwipe, int index, bool isMouse) { if (onlyFireWhenLiftCursor) { if (!isMouse) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.touches[i]; if (touch.fingerId == index) { return; } } } else { if (mouseIndex.Contains(index)) { //Debug.Log("mouse still down"); return; } if (Time.realtimeSinceStartup - timeStartSwipe > maxSwipeDuration) { //Debug.Log("too long "+(Time.realtimeSinceStartup-timeStartSwipe)); return; } } } Vector2 swipeDir = endPos - startPos; SwipeInfo sw = new SwipeInfo(startPos, endPos, swipeDir, timeStartSwipe, index, isMouse); IT_Gesture.SwipeEnd(sw); if ((swipeDir).magnitude < minDistance * IT_Gesture.GetDPIFactor()) { //GameMessage.DisplayMessage("too short"); return; } if (Time.time - lastSwipeTime < minDurationBetweenSwipe) { return; } lastSwipeTime = Time.time; IT_Gesture.Swipe(sw); //GameMessage.DisplayMessage("swiped"); }