void OnEnable() { Do(() => { for(int i=0; i<Input.touchCount; i++) { Touch t = new TouchTouch(Input.GetTouch(i)); if(t.phase == TouchPhase.Began) { StartCoroutine(Slide(t)); } } if(Input.touchCount == 0 && Input.GetMouseButton(0)) { StartCoroutine(Slide(new TouchMouse())); } return enabled; }); }
Vector3 InputPosition(int fingerId) { if (fingerId < 0) return Input.mousePosition; for(int i=0; i<Input.touchCount; i++) { Touch t = new TouchTouch(Input.GetTouch(i)); if (t.fingerId == fingerId) return t.position; } return Vector3.zero; }
bool GetFinger(int fingerId, out Touch touch) { if(fingerId < 0) { touch = new TouchMouse(); return true; } for(int i=0; i<Input.touchCount; i++) { Touch t = new TouchTouch(Input.GetTouch(i)); if (t.fingerId == fingerId) { touch = t; return true; } } touch = new TouchMouse(); return false; }