private void UpdateTouchPosition() { if (Input.touchCount == 0) { return; } var touch = Input.GetTouch(0); var touchPhase = touch.phase; var touchPosition = touch.position; if (touchPhase == TouchPhase.Began) { _touchStartPosition = touchPosition; InputStarted.Invoke(); return; } if (touchPhase == TouchPhase.Moved) { OnTouchMove(touchPosition); return; } if (touchPhase == TouchPhase.Ended) { OnTouchMove(touchPosition); InputEnded.Invoke(); } }
private void UpdateInputState(object sender, ElapsedEventArgs e) { var newInputDateTime = _inputSources.GetLastInputTime(); if (newInputDateTime.Subtract(_lastInputDateTime).TotalMilliseconds > 1000) { if (_lastInputDateTime.AddMilliseconds(_maxElapsedTimeMilliseconds) < newInputDateTime) { _lastInputUpdateDateTime = DateTime.Now; InputStarted?.Invoke(this, newInputDateTime); } else if (_lastInputUpdateDateTime.AddMilliseconds(_inputUpdateFrequencyMilliseconds) < DateTime.Now) { _lastInputUpdateDateTime = DateTime.Now; InputUpdated?.Invoke(this, newInputDateTime); } _lastInputDateTime = newInputDateTime; } }
private void UpdateClickPosition() { if (Input.GetMouseButtonDown(0)) { _touchStartPosition = Input.mousePosition; InputStarted.Invoke(); return; } if (Input.GetMouseButton(0)) { OnTouchMove(Input.mousePosition); return; } if (Input.GetMouseButtonUp(0)) { OnTouchMove(Input.mousePosition); InputEnded.Invoke(); } }