GesturePinchInput.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using UnityEngine;
  2. using UnityEngine.EventSystems;
  3. namespace Rokid.UXR.Interaction
  4. {
  5. public class GesturePinchInput : BaseInput
  6. {
  7. public override bool mousePresent => true;
  8. public override Vector2 mousePosition => GetGesPosition();
  9. public override bool touchSupported => true;
  10. public override int touchCount => 0;
  11. private bool mouseActive = false;
  12. public HandType hand = HandType.None;
  13. public void SetHandType(HandType hand)
  14. {
  15. this.hand = hand;
  16. }
  17. protected override void Awake()
  18. {
  19. base.Awake();
  20. }
  21. protected override void OnDestroy()
  22. {
  23. base.OnDestroy();
  24. }
  25. public override bool GetMouseButtonDown(int button)
  26. {
  27. return GesEventInput.Instance.GetHandDown(hand, true);
  28. }
  29. public override bool GetMouseButtonUp(int button)
  30. {
  31. return GesEventInput.Instance.GetHandUp(hand, true);
  32. }
  33. public override bool GetMouseButton(int button)
  34. {
  35. return GesEventInput.Instance.GetHandPress(hand, true);
  36. }
  37. public Vector2 GetGesPosition()
  38. {
  39. Vector2 gesPos = Vector2.zero;
  40. Gesture gesture = GesEventInput.Instance.GetGesture(hand);
  41. if (gesture != null)
  42. {
  43. gesPos = gesture.position;
  44. }
  45. return gesPos;
  46. }
  47. }
  48. }