void FixedTouchUpdate() { Gesture temp; foreach (UnityEngine.Touch t in Input.touches) { temp = GetGByID(t.fingerId); if (t.phase == TouchPhase.Canceled || t.phase == TouchPhase.Ended) { if (temp != null) { temp.AddTouch(GetTouch(t)); OnGestureEnd((Gesture)temp); g.Remove(temp); } } else { if (temp != null) temp.AddTouch(GetTouch(t)); else { temp = new Gesture(); temp.AddTouch(GetTouch(t)); g.Add(temp); OnGestureStart(temp); } } } }
void FixedMouseUpdate() { if (_pressed) if (v3tov2(Input.mousePosition) != _pos) _lg.AddTouch(GetDeltaTouch()); if (Input.GetMouseButton(0) && !_pressed) { _pressed = true; _pos = Input.mousePosition; _time = Time.time; // on start gesture _lg = new Gesture(); MouseTouch touch = new MouseTouch(); touch.position = _pos; touch.deltaTime = 0; touch.deltaPosition = Vector2.zero; touch.phase = TouchPhase.Began; touch.buttonID = 0; touch.Time = Time.time; _lg.AddTouch(touch); OnGestureStart(_lg); } if (!Input.GetMouseButton(0) && _pressed) { _pressed = false; // on finish gesture MouseTouch touch = GetDeltaTouch(); touch.phase = TouchPhase.Ended; _lg.AddTouch(touch); OnGestureEnd(_lg); } }