private IEnumerator DoSimulateTouch(SimulateTouchCommand command) { float lifeTime = command.duration; _fakeTouch.phase = TouchPhase.Began; _fakeTouch.position = command.from; _fakeTouch.deltaPosition = Vector3.zero; yield return(null); if (!command.isTap) { while (lifeTime >= 0) { lifeTime -= Time.deltaTime; _fakeTouch.phase = TouchPhase.Moved; var next = command.GetInterpolate(command.duration - lifeTime); _fakeTouch.deltaPosition = _fakeTouch.position - next; _fakeTouch.position = next; yield return(null); } _fakeTouch.phase = TouchPhase.Ended; _fakeTouch.deltaPosition = command.to - _fakeTouch.position; _fakeTouch.position = command.to; } else { _fakeTouch.phase = TouchPhase.Ended; _fakeTouch.position = command.to; _fakeTouch.deltaPosition = Vector3.zero; } yield return(null); _coroutine = null; }
public void AddSimulateTouch(SimulateTouchCommand command) { _queue.Enqueue(command); }