HandHeadSelector.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using UnityEngine;
  3. using Rokid.UXR.Utility;
  4. namespace Rokid.UXR.Interaction
  5. {
  6. /// <summary>
  7. /// Hand Selector
  8. /// </summary>
  9. public class HandHeadSelector : MonoBehaviour, ISelector, IHeadHandDriver
  10. {
  11. private bool press = false;
  12. public event Action WhenSelected;
  13. public event Action WhenUnselected;
  14. public void OnHandPress(HandType hand)
  15. {
  16. if (press == false)
  17. {
  18. press = true;
  19. WhenSelected?.Invoke();
  20. }
  21. }
  22. public void OnHandRelease()
  23. {
  24. if (press)
  25. {
  26. press = false;
  27. WhenUnselected?.Invoke();
  28. }
  29. }
  30. public void OnChangeHoldHandType(HandType hand)
  31. {
  32. }
  33. void Update()
  34. {
  35. if (Utils.IsUnityEditor())
  36. {
  37. if (Input.GetMouseButtonDown(0))
  38. {
  39. WhenSelected?.Invoke();
  40. }
  41. if (Input.GetMouseButtonUp(0))
  42. {
  43. WhenUnselected?.Invoke();
  44. }
  45. }
  46. }
  47. public void OnBeforeChangeHoldHandType(HandType hand)
  48. {
  49. }
  50. }
  51. }