void Update() { for (int i = 0; i < Input.touchCount; i++) { if ((left && Input.GetTouch(i).position.x < Screen.width / 2) || (!left && Input.GetTouch(i).position.x > Screen.width / 2)) { if (touchIndex == -1 || touchIndex > Input.touchCount) { touchIndex = i; } if (Input.GetTouch(touchIndex).phase == TouchPhase.Began) { Show(); } if (Input.GetTouch(touchIndex).phase == TouchPhase.Moved) { MoveJoystick(Input.GetTouch(touchIndex).position); } if (Input.GetTouch(touchIndex).phase == TouchPhase.Ended) { touchIndex = -1; Hide(); outerScript.Hide(); } return; } } if ((left && Input.mousePosition.x < Screen.width / 2) || (!left && Input.mousePosition.x > Screen.width / 2)) { if (Input.GetMouseButtonDown(0)) { Show(); } if (Input.GetMouseButton(0)) { MoveJoystick(Input.mousePosition); } if (Input.GetMouseButtonUp(0)) { Hide(); outerScript.Hide(); } } }