private void Update() { tap = swipeLeft = swipeRight = swipeUp = swipeDown = false; #region Standalone Inputs if (Input.GetMouseButtonDown(0)) { tap = true; isDraging = true; startTouch = Input.mousePosition; } else if (Input.GetMouseButtonUp(0)) { isDraging = false; Reset(); } #endregion #region Mobile Input if (Input.touches.Length > 0) { if (Input.touches[0].phase == TouchPhase.Began) { isDraging = true; tap = true; startTouch = Input.touches[0].position; } else if (Input.touches[0].phase == TouchPhase.Ended || Input.touches[0].phase == TouchPhase.Canceled) { isDraging = false; Reset(); } } #endregion // Calculate the distance swipeDelta = Vector2.zero; if (isDraging) { if (Input.touches.Length > 0) { swipeDelta = Input.touches[0].position - startTouch; } else if (Input.GetMouseButton(0)) { swipeDelta = (Vector2)Input.mousePosition - startTouch; } } //Did we cross the distance? if (swipeDelta.magnitude > 125) { //Which direction? float x = swipeDelta.x; float y = swipeDelta.y; if (Mathf.Abs(x) > Mathf.Abs(y)) { //Left or right if (x < 0) { swipeLeft = true; kontrol.SagaGit(); } else { swipeLeft = true; kontrol.SolaGit(); } } else { // Up or down if (y < 0) { swipeDown = true; } else { swipeUp = true; } } Reset(); } }