InputModuleSwitchActive.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using System;
  2. using UnityEngine;
  3. namespace Rokid.UXR.Interaction
  4. {
  5. [Serializable]
  6. public class HandActiveDetail
  7. {
  8. [SerializeField, Tooltip("是否在手丢失的时候禁用")]
  9. public bool DisableOnHandLost = true;
  10. [SerializeField, Tooltip("左右手的激活类型")]
  11. public ActiveHandType activeHandType = ActiveHandType.LeftHand | ActiveHandType.RightHand;
  12. [SerializeField, Tooltip("远近场的激活类型")]
  13. public ActiveHandInteractorType activeHandInteractorType = ActiveHandInteractorType.Far | ActiveHandInteractorType.Near;
  14. [SerializeField, Tooltip("手心手背的激活类型")]
  15. public ActiveHandOrientationType activeHandOrientationType = ActiveHandOrientationType.Back | ActiveHandOrientationType.Palm;
  16. [SerializeField, Tooltip("默认手势交互|头手交互")]
  17. public ActiveHeadHandType activeHeadHandType = ActiveHeadHandType.NormalHand | ActiveHeadHandType.HeadHand;
  18. [SerializeField, Tooltip("手表模式的激活类型")]
  19. public ActiveWatchType activeWatchType = ActiveWatchType.DisableWatch | ActiveWatchType.EnableWatch;
  20. }
  21. /// <summary>
  22. /// This script implements the IInputModuleActive interface, which allows it to register its own activation status information to the InputModuleManager for centralized management and switching.
  23. /// </summary>
  24. public class InputModuleSwitchActive : MonoBehaviour, IInputModuleActive
  25. {
  26. [SerializeField, Optional, Tooltip("禁用/激活的Behaviour组件,如果为空则禁用/激活gameobject")]
  27. private MonoBehaviour behaviour;
  28. [SerializeField, Tooltip("交互模块的激活类型")]
  29. private ActiveModuleType activeModuleType;
  30. [SerializeField, Tooltip("手势的交互的激活细节")]
  31. private HandActiveDetail handActiveDetail;
  32. MonoBehaviour IInputModuleActive.Behaviour => this.behaviour;
  33. public GameObject Go => this.gameObject;
  34. ActiveModuleType IInputModuleActive.ActiveModuleType => this.activeModuleType;
  35. ActiveHandType IInputModuleActive.ActiveHandType => this.handActiveDetail.activeHandType;
  36. ActiveHandInteractorType IInputModuleActive.ActiveHandInteractorType => this.handActiveDetail.activeHandInteractorType;
  37. ActiveHandOrientationType IInputModuleActive.ActiveHandOrientationType => this.handActiveDetail.activeHandOrientationType;
  38. public ActiveWatchType ActiveWatchType => this.handActiveDetail.activeWatchType;
  39. public ActiveHeadHandType ActiveHeadHandType => this.handActiveDetail.activeHeadHandType;
  40. public bool DisableOnHandLost => this.handActiveDetail.DisableOnHandLost;
  41. private void Start()
  42. {
  43. InputModuleManager.Instance.RegisterActive(this);
  44. }
  45. private void OnDestroy()
  46. {
  47. InputModuleManager.Instance.UnRegisterActive(this);
  48. }
  49. }
  50. }