private void CheckFingerGroup(Touch touch) { bool flag = false; for (int i = 0; i < this.fingerGroup.Count; i++) { FingerGroup fingerGroup = this.fingerGroup[i]; if (!(Time.realtimeSinceStartup - fingerGroup.triggerTime < shortTapTime / 2f)) { continue; } bool flag2 = true; for (int j = 0; j < fingerGroup.indexes.Count; j++) { int iD = fingerGroup.indexes[j]; if (Vector2.Distance(IT_Gesture.GetTouch(iD).position, touch.position) > maxFingerGroupDist * IT_Gesture.GetDPIFactor()) { flag2 = false; } } if (flag2) { fingerGroup.indexes.Add(touch.fingerId); fingerGroup.positions.Add(touch.position); flag = true; break; } } if (!flag) { this.fingerGroup.Add(new FingerGroup(Time.realtimeSinceStartup, touch.fingerId, touch.position)); StartCoroutine(this.fingerGroup[this.fingerGroup.Count - 1].Routine(this)); } }
private IEnumerator TouchRoutine(int index) { fingerIndex.Add(index); bool dragStarted = false; Vector2 startPos = IT_Gesture.GetTouch(index).position; Vector2 lastPos = startPos; float timeStart = float.PositiveInfinity; while ((enableMultiDrag && Input.touchCount > 0) || (!enableMultiDrag && Input.touchCount == 1)) { Touch touch = IT_Gesture.GetTouch(index); if (touch.position == Vector2.zero) { break; } Vector2 curPos = touch.position; if (touch.phase == TouchPhase.Moved) { if (!dragStarted) { if (Vector3.Distance(curPos, startPos) > (float)minDragDistance * IT_Gesture.GetDPIFactor()) { dragStarted = true; Vector2 delta3 = curPos - startPos; DragInfo dragInfo4 = new DragInfo(curPos, delta3, 1, index, im: false); IT_Gesture.DraggingStart(dragInfo4); timeStart = Time.realtimeSinceStartup; } } else if (curPos != lastPos) { Vector2 delta2 = curPos - lastPos; DragInfo dragInfo3 = new DragInfo(curPos, delta2, 1, index, im: false); IT_Gesture.Dragging(dragInfo3); } lastPos = curPos; } else if (dragStarted && fireOnDraggingWhenNotMoving) { DragInfo dragInfo2 = new DragInfo(curPos, Vector2.zero, 1, index, im: false); IT_Gesture.Dragging(dragInfo2); } yield return(null); } if (dragStarted) { bool isFlick = false; if (Time.realtimeSinceStartup - timeStart < flickTimeRange) { isFlick = true; } Vector2 delta = lastPos - startPos; DragInfo dragInfo = new DragInfo(lastPos, delta, 1, index, isFlick, im: false); IT_Gesture.DraggingEnd(dragInfo); } fingerIndex.Remove(index); }
void CheckFingerGroup(Touch touch) { //Debug.Log("Checking "+Time.realtimeSinceStartup); bool match = false; //foreach(FingerGroup group in fingerGroup){ for (int i = 0; i < fingerGroup.Count; i++) { FingerGroup group = fingerGroup[i]; if (Time.realtimeSinceStartup - group.triggerTime < shortTapTime / 2) { bool inRange = true; float dist = 0; //foreach(int index in group.indexes){ for (int j = 0; j < group.indexes.Count; j++) { int index = group.indexes[j]; dist = Vector2.Distance(IT_Gesture.GetTouch(index).position, touch.position); if (Vector2.Distance(IT_Gesture.GetTouch(index).position, touch.position) > maxFingerGroupDist * IT_Gesture.GetDPIFactor()) { inRange = false; } } if (inRange) { group.indexes.Add(touch.fingerId); group.positions.Add(touch.position); match = true; break; } } } if (!match) { fingerGroup.Add(new FingerGroup(Time.realtimeSinceStartup, touch.fingerId, touch.position)); StartCoroutine(fingerGroup[fingerGroup.Count - 1].Routine(this)); } }
IEnumerator TouchSwipeRoutine(int index) { //GameMessage.DisplayMessage("swipe routine started"); fingerIndex.Add(index); float timeStartSwipe = Time.realtimeSinceStartup; Vector2 initialPos; Vector2 startPos; Vector2 initVector = Vector2.zero; Vector2 lastPos = Vector2.zero; _SwipeState swipeState = _SwipeState.None; lastPos = IT_Gesture.GetTouch(index).position; startPos = lastPos; initialPos = lastPos; int count = 0; yield return(null); while (Input.touchCount > 0) { if (!enableMultiSwipe && Input.touchCount > 1) { break; } Touch touch = IT_Gesture.GetTouch(index); if (touch.position == Vector2.zero) { break; } Vector2 curPos = touch.position; Vector2 curVector = curPos - lastPos; float mag = curVector.magnitude; count += 1; if (swipeState == _SwipeState.None && mag > 0) { timeStartSwipe = Time.realtimeSinceStartup; //startPos=curPos; startPos = initialPos; swipeState = _SwipeState.Swiping; initVector = curVector; count = 1; SwipeStart(startPos, curPos, timeStartSwipe, index, false); } else if (swipeState == _SwipeState.Swiping) { if (count < 3) { initVector = (initVector + curVector) * 0.5f; } if (mag > 0) { Swiping(startPos, curPos, timeStartSwipe, index, false); if (curPos.x < 0 || curPos.x > Screen.width || curPos.y < 0 || curPos.y > Screen.height) { //GameMessage.DisplayMessage("out of bound"); swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index, true); initialPos = curPos; } if (Time.realtimeSinceStartup - timeStartSwipe > maxSwipeDuration) { //GameMessage.DisplayMessage("duration due"); swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } //check angle if (Mathf.Abs(Vector2.Angle(initVector, curVector)) > maxDirectionChange) { //GameMessage.DisplayMessage("angle is too wide "+initVector+" "+curVector); swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } //check speed if (Mathf.Abs((curPos - startPos).magnitude / (Time.realtimeSinceStartup - timeStartSwipe)) < minSpeed) { //GameMessage.DisplayMessage("too slow"); swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } } } lastPos = curPos; yield return(null); } if (swipeState == _SwipeState.Swiping) { swipeState = _SwipeState.None; SwipeEnd(startPos, lastPos, timeStartSwipe, index); } fingerIndex.Remove(index); //GameMessage.DisplayMessage("swipe routine ended"); }
public IEnumerator Routine(TapDetector tapD) { tapDetector = tapD; triggerTime = Time.realtimeSinceStartup; startTimeCharge = Time.realtimeSinceStartup; yield return(new WaitForSeconds(0.075f)); if (indexes.Count < 2) { routineEnded = true; yield break; } else { count = indexes.Count; posAvg = Vector2.zero; //foreach(Vector2 p in positions) posAvg+=p; for (int i = 0; i < positions.Count; i++) { posAvg += positions[i]; } posAvg /= positions.Count; posList = new Vector2[positions.Count]; positions.CopyTo(posList); indexList = new int[indexes.Count]; indexes.CopyTo(indexList); } bool isOn = true; float liftTime = -1; int rand = Random.Range(0, 99999); while (isOn) { for (int i = 0; i < indexes.Count; i++) { Touch touch = IT_Gesture.GetTouch(indexes[i]); if (touch.phase == TouchPhase.Moved) { isOn = false; } if (touch.position == Vector2.zero) { if (indexes.Count == count) { liftTime = Time.realtimeSinceStartup; } indexes.RemoveAt(i); i--; } } if (Time.realtimeSinceStartup - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear) { chargeState = _ChargeState.Charging; float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(posAvg, posList, chargedValue, indexList); IT_Gesture.ChargeStart(cInfo); } else if (chargeState == _ChargeState.Charging) { float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(posAvg, posList, chargedValue, indexList); if (tapDetector.chargeMode == _ChargeMode.PingPong) { if (chargedValue == 1 || chargedValue == 0) { chargeDir *= -1; if (chargeDir == 1) { chargeConst = 0; } else if (chargeDir == -1) { chargeConst = 1; } startTimeCharge = Time.realtimeSinceStartup; } IT_Gesture.Charging(cInfo); } else { if (chargedValue < 1.0f) { IT_Gesture.Charging(cInfo); } else { cInfo.percent = 1.0f; if (tapDetector.chargeMode == _ChargeMode.Once) { chargeState = _ChargeState.Charged; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = Mathf.Infinity; chargedValue = 0; } else if (tapDetector.chargeMode == _ChargeMode.Clamp) { chargeState = _ChargeState.Charged; IT_Gesture.Charging(cInfo); } else if (tapDetector.chargeMode == _ChargeMode.Loop) { chargeState = _ChargeState.Clear; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = Time.realtimeSinceStartup; } } } } if (!longTap && Time.realtimeSinceStartup - triggerTime > tapDetector.longTapTime) { if (indexes.Count == count) { Vector2[] posList = new Vector2[positions.Count]; positions.CopyTo(posList); Tap tap = new Tap(1, count, posList, indexList); IT_Gesture.LongTap(tap); longTap = true; } } if (indexes.Count < count) { if (Time.realtimeSinceStartup - liftTime > 0.075f || indexes.Count == 0) { if (indexes.Count == 0) { if (liftTime - triggerTime < tapDetector.shortTapTime + 0.1f) { Vector2[] posList = new Vector2[positions.Count]; positions.CopyTo(posList); //Tap tap=new Tap(1, count, posList); //IT_Gesture.MFShortTap(tap); tapDetector.CheckMultiTapMFTouch(count, posList, indexList); } } isOn = false; break; } } yield return(null); } if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != _ChargeMode.Once)) { float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(posAvg, posList, chargedValue, indexList); IT_Gesture.ChargeEnd(cInfo); } routineEnded = true; }
IEnumerator FingerRoutine(int index) { fingerIndex.Add(index); //init tap variables Touch touch = IT_Gesture.GetTouch(index); float startTime = Time.realtimeSinceStartup; Vector2 startPos = touch.position; Vector2 lastPos = startPos; bool longTap = false; //init charge variables _ChargeState chargeState = _ChargeState.Clear; int chargeDir = 1; int chargeConst = 0; float startTimeCharge = Time.realtimeSinceStartup; Vector2 startPosCharge = touch.position; //yield return null; bool inGroup = false; while (true) { touch = IT_Gesture.GetTouch(index); if (touch.position == Vector2.zero) { break; } Vector2 curPos = touch.position; if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear) { chargeState = _ChargeState.Charging; float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(curPos, chargedValue, index, false); IT_Gesture.ChargeStart(cInfo); startPosCharge = curPos; } else if (chargeState == _ChargeState.Charging) { if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation) { chargeState = _ChargeState.Clear; float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(lastPos, chargedValue, index, false); IT_Gesture.ChargeEnd(cInfo); } else { float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(curPos, chargedValue, index, false); if (chargeMode == _ChargeMode.PingPong) { if (chargedValue == 1 || chargedValue == 0) { chargeDir *= -1; if (chargeDir == 1) { chargeConst = 0; } else if (chargeDir == -1) { chargeConst = 1; } startTimeCharge = Time.realtimeSinceStartup; } IT_Gesture.Charging(cInfo); } else { if (chargedValue < 1.0f) { IT_Gesture.Charging(cInfo); } else { cInfo.percent = 1.0f; if (chargeMode == _ChargeMode.Once) { chargeState = _ChargeState.Charged; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = Mathf.Infinity; chargedValue = 0; } else if (chargeMode == _ChargeMode.Clamp) { chargeState = _ChargeState.Charged; IT_Gesture.Charging(cInfo); } else if (chargeMode == _ChargeMode.Loop) { chargeState = _ChargeState.Clear; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = Time.realtimeSinceStartup; } } } } } if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor()) { //new Tap(multiTapMFTouch[index].count, fCount, posL) //IT_Gesture.LongTap(new Tap(multiTapMFTouch[index].count, fCount, posL)); IT_Gesture.LongTap(new Tap(curPos, 1, index, false)); //IT_Gesture.LongTap(startPos); longTap = true; } lastPos = curPos; if (!inGroup) { inGroup = IndexInFingerGroup(index); } yield return(null); } //check for shortTap if (!inGroup) { if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor()) { CheckMultiTapTouch(index, startPos, lastPos); } } //check for charge if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != _ChargeMode.Once)) { float chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1); ChargedInfo cInfo = new ChargedInfo(lastPos, chargedValue, index, false); IT_Gesture.ChargeEnd(cInfo); } fingerIndex.Remove(index); }
private IEnumerator FingerRoutine(int index) { fingerIndex.Add(index); Touch touch2 = IT_Gesture.GetTouch(index); float startTime = Time.realtimeSinceStartup; Vector2 startPos = touch2.position; Vector2 lastPos = startPos; bool longTap = false; _ChargeState chargeState = _ChargeState.Clear; int chargeDir = 1; int chargeConst = 0; float startTimeCharge = Time.realtimeSinceStartup; Vector2 startPosCharge = touch2.position; while (true) { touch2 = IT_Gesture.GetTouch(index); if (touch2.position == Vector2.zero) { break; } Vector2 curPos = touch2.position; if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear) { chargeState = _ChargeState.Charging; float chargedValue3 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f); ChargedInfo cInfo3 = new ChargedInfo(curPos, chargedValue3, index, im: false); IT_Gesture.ChargeStart(cInfo3); startPosCharge = curPos; } else if (chargeState == _ChargeState.Charging) { if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation) { chargeState = _ChargeState.Clear; float chargedValue2 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f); ChargedInfo cInfo2 = new ChargedInfo(lastPos, chargedValue2, index, im: false); IT_Gesture.ChargeEnd(cInfo2); } else { float chargedValue = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f); ChargedInfo cInfo = new ChargedInfo(curPos, chargedValue, index, im: false); if (chargeMode == _ChargeMode.PingPong) { if (chargedValue == 1f || chargedValue == 0f) { chargeDir *= -1; switch (chargeDir) { case 1: chargeConst = 0; break; case -1: chargeConst = 1; break; } startTimeCharge = Time.realtimeSinceStartup; } IT_Gesture.Charging(cInfo); } else if (chargedValue < 1f) { IT_Gesture.Charging(cInfo); } else { cInfo.percent = 1f; if (chargeMode == _ChargeMode.Once) { chargeState = _ChargeState.Charged; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = float.PositiveInfinity; } else if (chargeMode == _ChargeMode.Clamp) { chargeState = _ChargeState.Charged; IT_Gesture.Charging(cInfo); } else if (chargeMode == _ChargeMode.Loop) { chargeState = _ChargeState.Clear; IT_Gesture.ChargeEnd(cInfo); startTimeCharge = Time.realtimeSinceStartup; } } } } if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor()) { IT_Gesture.LongTap(new Tap(curPos, 1, index, im: false)); longTap = true; } lastPos = curPos; yield return(null); } if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor()) { CheckMultiTapTouch(index, startPos, lastPos); } if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != 0)) { float chargedValue4 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f); ChargedInfo cInfo4 = new ChargedInfo(lastPos, chargedValue4, index, im: false); IT_Gesture.ChargeEnd(cInfo4); } fingerIndex.Remove(index); }
public IEnumerator Routine(TapDetector tapD) { tapDetector = tapD; triggerTime = Time.realtimeSinceStartup; startTimeCharge = Time.realtimeSinceStartup; yield return(new WaitForSeconds(0.075f)); if (indexes.Count < 2) { routineEnded = true; yield break; } count = indexes.Count; posAvg = Vector2.zero; for (int i = 0; i < positions.Count; i++) { posAvg += positions[i]; } posAvg /= (float)positions.Count; this.posList = new Vector2[positions.Count]; positions.CopyTo(this.posList); indexList = new int[indexes.Count]; indexes.CopyTo(indexList); bool isOn = true; float liftTime = -1f; while (isOn) { for (int j = 0; j < indexes.Count; j++) { Touch touch = IT_Gesture.GetTouch(indexes[j]); if (touch.phase == TouchPhase.Moved) { isOn = false; } if (touch.position == Vector2.zero) { if (indexes.Count == count) { liftTime = Time.realtimeSinceStartup; } indexes.RemoveAt(j); j--; } } if (Time.realtimeSinceStartup - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear) { chargeState = _ChargeState.Charging; ChargedInfo cInfo3 = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList); IT_Gesture.ChargeStart(cInfo3); } else if (chargeState == _ChargeState.Charging) { float chargedValue = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f); ChargedInfo cInfo2 = new ChargedInfo(posAvg, this.posList, chargedValue, indexList); if (tapDetector.chargeMode == _ChargeMode.PingPong) { if (chargedValue == 1f || chargedValue == 0f) { chargeDir *= -1; if (chargeDir == 1) { chargeConst = 0; } else if (chargeDir == -1) { chargeConst = 1; } startTimeCharge = Time.realtimeSinceStartup; } IT_Gesture.Charging(cInfo2); } else if (chargedValue < 1f) { IT_Gesture.Charging(cInfo2); } else { cInfo2.percent = 1f; if (tapDetector.chargeMode == _ChargeMode.Once) { chargeState = _ChargeState.Charged; IT_Gesture.ChargeEnd(cInfo2); startTimeCharge = float.PositiveInfinity; } else if (tapDetector.chargeMode == _ChargeMode.Clamp) { chargeState = _ChargeState.Charged; IT_Gesture.Charging(cInfo2); } else if (tapDetector.chargeMode == _ChargeMode.Loop) { chargeState = _ChargeState.Clear; IT_Gesture.ChargeEnd(cInfo2); startTimeCharge = Time.realtimeSinceStartup; } } } if (!longTap && Time.realtimeSinceStartup - triggerTime > tapDetector.longTapTime && indexes.Count == count) { Vector2[] posList2 = new Vector2[positions.Count]; positions.CopyTo(posList2); Tap tap = new Tap(1, count, posList2, indexList); IT_Gesture.LongTap(tap); longTap = true; } if (indexes.Count < count && (Time.realtimeSinceStartup - liftTime > 0.075f || indexes.Count == 0)) { if (indexes.Count == 0 && liftTime - triggerTime < tapDetector.shortTapTime + 0.1f) { Vector2[] posList = new Vector2[positions.Count]; positions.CopyTo(posList); tapDetector.CheckMultiTapMFTouch(count, posList, indexList); } break; } yield return(null); } if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != 0)) { ChargedInfo cInfo = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList); IT_Gesture.ChargeEnd(cInfo); } routineEnded = true; }
private IEnumerator TouchSwipeRoutine(int index) { fingerIndex.Add(index); float timeStartSwipe = Time.realtimeSinceStartup; Vector2 initVector = Vector2.zero; Vector2 zero = Vector2.zero; _SwipeState swipeState = _SwipeState.None; Vector2 lastPos = IT_Gesture.GetTouch(index).position; Vector2 startPos = lastPos; Vector2 initialPos = lastPos; int count = 0; yield return(null); while (Input.touchCount > 0 && (enableMultiSwipe || Input.touchCount <= 1)) { Touch touch = IT_Gesture.GetTouch(index); if (touch.position == Vector2.zero) { break; } Vector2 curPos = touch.position; Vector2 curVector = curPos - lastPos; float mag = curVector.magnitude; count++; if (swipeState == _SwipeState.None && mag > 0f) { timeStartSwipe = Time.realtimeSinceStartup; startPos = initialPos; swipeState = _SwipeState.Swiping; initVector = curVector; count = 1; SwipeStart(startPos, curPos, timeStartSwipe, index, isMouse: false); } else if (swipeState == _SwipeState.Swiping) { if (count < 3) { initVector = (initVector + curVector) * 0.5f; } if (mag > 0f) { Swiping(startPos, curPos, timeStartSwipe, index, isMouse: false); if (curPos.x < 0f || curPos.x > (float)Screen.width || curPos.y < 0f || curPos.y > (float)Screen.height) { swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index, isMouse: true); initialPos = curPos; } if (Time.realtimeSinceStartup - timeStartSwipe > maxSwipeDuration) { swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } if (Mathf.Abs(Vector2.Angle(initVector, curVector)) > maxDirectionChange) { swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } if (Mathf.Abs((curPos - startPos).magnitude / (Time.realtimeSinceStartup - timeStartSwipe)) < minSpeed) { swipeState = _SwipeState.None; SwipeEnd(startPos, curPos, timeStartSwipe, index); initialPos = curPos; } } } lastPos = curPos; yield return(null); } if (swipeState == _SwipeState.Swiping) { SwipeEnd(startPos, lastPos, timeStartSwipe, index); } fingerIndex.Remove(index); }