private void HandleMobileSwipe() { if (Input.touchCount > 0) { if (Input.GetTouch(0).phase == TouchPhase.Began) { startTime = Time.time; finalPosition = Vector3.zero; length = 0; SW = false; Vector2 touchDeltaPosition = Input.GetTouch(0).position; startpos = new Vector3(touchDeltaPosition.x, 0, touchDeltaPosition.y); oldpos = startpos; } if (Input.GetTouch(0).phase == TouchPhase.Moved) { SW = true; Vector2 touchDeltaPosition = Input.GetTouch(0).position; Vector3 pos = new Vector3(touchDeltaPosition.x, 0, touchDeltaPosition.y); if (handleSwipes && pos.x != oldpos.x) { var f = pos - oldpos; var l = f.x < 0 ? (f.magnitude * Time.deltaTime) : -(f.magnitude * Time.deltaTime); l *= .2f; // Menu.instance.Constant (l); levelMenu.move((-l * 200f)); levelMenu.debugtext(l.ToString()); } oldpos = pos; } if (Input.GetTouch(0).phase == TouchPhase.Canceled) { SW = false; levelMenu.swipePage(15); } if (Input.GetTouch(0).phase == TouchPhase.Stationary) { SW = false; } if (Input.GetTouch(0).phase == TouchPhase.Ended) { // if (SW) { // } // if (SW && handleFlicks) { Vector2 touchPosition = Input.GetTouch(0).position; endpos = new Vector3(touchPosition.x, 0, touchPosition.y); finalPosition = endpos - startpos; length = finalPosition.x < 0 ? -(finalPosition.magnitude * Time.deltaTime) : (finalPosition.magnitude * Time.deltaTime); length *= .35f; var force = length / (Time.time - startTime); force = Mathf.Clamp(force, -maxForce, maxForce); levelMenu.swipePage(force); // if (handleFlicks && Mathf.Abs (force) > requiredForceForFlick) { //// Menu.instance.Inertia (-length); // // } else if (lockToClosest && force != 0) { //// Menu.instance.LockToClosest (); // // } // } } } }