Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void MouseMethod()
- {
- foreach (Touch touch in Input.touches)
- {
- HandleTouch(touch.fingerId,touch.position, touch.phase);
- }
- // Simulate touch events from mouse events
- if (Input.touchCount == 0)
- {
- if (Input.GetMouseButtonDown(0))
- {
- HandleTouch(10, Input.mousePosition, TouchPhase.Began);
- }
- if (Input.GetMouseButton(0))
- {
- HandleTouch(10, Input.mousePosition, TouchPhase.Moved);
- }
- if (Input.GetMouseButtonUp(0))
- {
- HandleTouch(10, Input.mousePosition, TouchPhase.Ended);
- }
- }
- }
- private void HandleTouch(int touchFingerId, Vector3 touchPosition, TouchPhase touchPhase)
- {
- switch (touchPhase)
- {
- case TouchPhase.Began:
- Debug.Log("Беган");
- break;
- case TouchPhase.Moved:
- Debug.Log("мувд");
- break;
- case TouchPhase.Ended:
- Debug.Log("end");
- break;
- }
- }
- foreach (var th in Input.touches)
- {
- if (th.phase == TouchPhase.Began && (th.phase != TouchPhase.Moved))
- {
- TouchBegan(th);
- }
- if (th.fingerId == fId && ((th.phase == TouchPhase.Moved) || (th.phase == TouchPhase.Stationary)))
- {
- TouchMovedOrStationary(th);
- }
- if (th.fingerId == fId && (th.phase == TouchPhase.Ended || th.phase == TouchPhase.Canceled))
- {
- TouchEnded();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement