Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. void MouseMethod()
  2. {
  3. foreach (Touch touch in Input.touches)
  4. {
  5. HandleTouch(touch.fingerId,touch.position, touch.phase);
  6. }
  7.  
  8. // Simulate touch events from mouse events
  9. if (Input.touchCount == 0)
  10. {
  11. if (Input.GetMouseButtonDown(0))
  12. {
  13. HandleTouch(10, Input.mousePosition, TouchPhase.Began);
  14. }
  15. if (Input.GetMouseButton(0))
  16. {
  17. HandleTouch(10, Input.mousePosition, TouchPhase.Moved);
  18. }
  19. if (Input.GetMouseButtonUp(0))
  20. {
  21. HandleTouch(10, Input.mousePosition, TouchPhase.Ended);
  22. }
  23. }
  24. }
  25.  
  26. private void HandleTouch(int touchFingerId, Vector3 touchPosition, TouchPhase touchPhase)
  27. {
  28.  
  29. switch (touchPhase)
  30. {
  31. case TouchPhase.Began:
  32. Debug.Log("Беган");
  33. break;
  34. case TouchPhase.Moved:
  35. Debug.Log("мувд");
  36. break;
  37. case TouchPhase.Ended:
  38. Debug.Log("end");
  39. break;
  40. }
  41. }
  42.  
  43. foreach (var th in Input.touches)
  44. {
  45. if (th.phase == TouchPhase.Began && (th.phase != TouchPhase.Moved))
  46. {
  47. TouchBegan(th);
  48. }
  49. if (th.fingerId == fId && ((th.phase == TouchPhase.Moved) || (th.phase == TouchPhase.Stationary)))
  50. {
  51. TouchMovedOrStationary(th);
  52. }
  53. if (th.fingerId == fId && (th.phase == TouchPhase.Ended || th.phase == TouchPhase.Canceled))
  54. {
  55. TouchEnded();
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement