123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763 |
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using UnityEngine.EventSystems;
- using Rokid.UXR.Utility;
- using Rokid.UXR.Module;
- namespace Rokid.UXR.Interaction
- {
- public enum InputModuleType
- {
- None = 1 << 0,
- ThreeDof = 1 << 1, //手机3dof 射线
- Gesture = 1 << 2, //手势
- Mouse = 1 << 3, // 蓝牙鼠标
- ButtonMouse = 1 << 4, // 滑鼠
- TouchPad = 1 << 5, // 触摸屏
- }
- [Flags]
- public enum ActiveModuleType
- {
- ThreeDof = 1 << 0, //手机 3dof 射线
- Gesture = 1 << 1, //手势
- Mouse = 1 << 2, // 蓝牙鼠标
- ButtonMouse = 1 << 3, // 滑鼠
- TouchPad = 1 << 4, // 触摸屏
- }
- [Flags]
- public enum ActiveHandType
- {
- LeftHand = 1 << 0, //左手
- RightHand = 1 << 1, //右手
- }
- [Flags]
- public enum ActiveHandOrientationType
- {
- Back = 1 << 0, //左手
- Palm = 1 << 1, //右手
- }
- [Flags]
- public enum ActiveHandInteractorType
- {
- Far = 1 << 0, //远场交互
- Near = 1 << 1, //进场交互
- }
- [Flags]
- public enum ActiveWatchType
- {
- DisableWatch = 1 << 0,
- EnableWatch = 1 << 1,
- }
- [Flags]
- public enum ActiveHeadHandType
- {
- NormalHand = 1 << 0,
- HeadHand = 1 << 1,
- }
- /// <summary>
- /// Input Module status
- /// </summary>
- [Serializable]
- public class ActiveModuleStatus
- {
- public InputModuleType moduleType;
- public ActiveHandStatus leftHandStatus;
- public ActiveHandStatus rightHandStatus;
- public ActiveHeadHandType headHandType;
- public override string ToString()
- {
- return $"ActiveInputModuleType: {moduleType} \r\n\r\nLeftHandStatus: {leftHandStatus.ToString()} \r\n\r\nRightHandStatus: {rightHandStatus.ToString()}";
- }
- }
- [Serializable]
- public class ActiveHandStatus
- {
- public bool active;
- public ActiveHandInteractorType handInteractorType;
- public ActiveHandOrientationType handOrientationType;
- public ActiveWatchType activeWatchType;
- public bool handDragging;
- public override string ToString()
- {
- return $" \r\n Active:{active} \r\n HandDragging:{handDragging}\r\n HandInteractorType:{handInteractorType.ToString()} \r\n HandOrientationType:{handOrientationType.ToString()} \r\n ActiveWatchType:{activeWatchType.ToString()}";
- }
- }
- /// <summary>
- /// This script implements the IInputModuleActive interface, which allows it to register its own activation status information to the InputModuleManager for centralized management and switching.
- /// </summary>
- public class InputModuleManager : MonoSingleton<InputModuleManager>
- {
- /// <summary>
- /// The default init module
- /// </summary>
- [SerializeField, Tooltip("默认初始化的模块")]
- private ActiveModuleType defaultInitModule;
- /// <summary>
- /// The default active module.
- /// </summary>
- [SerializeField, Tooltip("默认激活的模块")]
- private InputModuleType defaultActiveModule;
- /// <summary>
- /// Whether to play a module switch sound.
- /// </summary>
- [HideInInspector, SerializeField, Tooltip("是否播放模块切换提示音")]
- private bool muteModuleActiveSound = false;
- /// <summary>
- /// Optional TextUI for debugging purposes.
- /// </summary>
- [Optional, SerializeField, Tooltip("调试Text")]
- private Text logText;
- [SerializeField, HideInInspector, Tooltip("模块的激活状态")]
- private ActiveModuleStatus activeModuleStatus = new ActiveModuleStatus();
- private bool stateChanged;
- private List<IInputModuleActive> moduleActives = new List<IInputModuleActive>();
- public static event Action<IInputModuleActive, bool> OnObjectActive;
- public static event Action<InputModuleType> OnModuleActive;
- public bool GetMouseActive()
- {
- return activeModuleStatus.moduleType == InputModuleType.Mouse;
- }
- public bool GetGesActive()
- {
- return activeModuleStatus.moduleType == InputModuleType.Gesture;
- }
- public bool GetThreeDofActive()
- {
- return activeModuleStatus.moduleType == InputModuleType.ThreeDof;
- }
- public bool GetButtonMouseActive()
- {
- return activeModuleStatus.moduleType == InputModuleType.ButtonMouse;
- }
- public bool GetTouchPadActive()
- {
- return activeModuleStatus.moduleType == InputModuleType.TouchPad;
- }
- public bool GetWatchModuleActive(HandType hand)
- {
- if (activeModuleStatus.moduleType == InputModuleType.Gesture)
- {
- if (hand == HandType.LeftHand)
- {
- return activeModuleStatus.leftHandStatus.activeWatchType == ActiveWatchType.EnableWatch;
- }
- if (hand == HandType.RightHand)
- {
- return activeModuleStatus.rightHandStatus.activeWatchType == ActiveWatchType.EnableWatch;
- }
- }
- return false;
- }
- /// <summary>
- /// 获取当前激活的模块
- /// Gets the currently active module
- /// </summary>
- /// <returns></returns>
- public ActiveModuleStatus GetActiveModule()
- {
- return activeModuleStatus;
- }
- public void SetDefaultActiveModule(InputModuleType moduleType)
- {
- defaultActiveModule = moduleType;
- }
- public void Initialize()
- {
- RKLog.KeyInfo($"====InputModuleManager====: defaultInitModule : {defaultInitModule}, defaultActiveModule:{defaultActiveModule},transform:{transform.name}");
- if (HasInputModuleType(defaultInitModule, ActiveModuleType.ThreeDof))
- {
- ThreeDofEventInput.Instance.Initialize(transform);
- }
- if (HasInputModuleType(defaultInitModule, ActiveModuleType.Mouse))
- {
- MouseEventInput.Instance.Initialize(transform);
- }
- if (HasInputModuleType(defaultInitModule, ActiveModuleType.ButtonMouse))
- {
- ButtonMouseEventInput.Instance.Initialize(transform);
- }
- if (HasInputModuleType(defaultInitModule, ActiveModuleType.Gesture))
- {
- if (Utils.IsAndroidPlatfrom())
- {
- if (Utils.IsAndroidPlatfrom() && FuncDeviceCheck.CheckHandTrackingFunc())
- {
- GesEventInput.Instance.Initialize(transform);
- }
- else
- {
- ThreeDofEventInput.Instance.Initialize(transform);
- }
- }
- else
- {
- GesEventInput.Instance.Initialize(transform);
- }
- }
- if (HasInputModuleType(defaultInitModule, ActiveModuleType.TouchPad))
- {
- TouchPadEventInput.Instance.Initialize(transform);
- }
- switch (defaultActiveModule)
- {
- case InputModuleType.ThreeDof:
- ThreeDofEventInput.Instance.ActiveModule();
- break;
- case InputModuleType.Gesture:
- if (Utils.IsAndroidPlatfrom())
- {
- if (FuncDeviceCheck.CheckHandTrackingFunc())
- {
- GesEventInput.Instance.ActiveModule();
- }
- else
- {
- ThreeDofEventInput.Instance.ActiveModule();
- }
- }
- else
- {
- GesEventInput.Instance.ActiveModule();
- }
- break;
- case InputModuleType.Mouse:
- MouseEventInput.Instance.ActiveModule();
- break;
- case InputModuleType.ButtonMouse:
- ButtonMouseEventInput.Instance.ActiveModule();
- break;
- case InputModuleType.TouchPad:
- TouchPadEventInput.Instance.ActiveModule();
- break;
- }
- if (EventSystem.current == null)
- {
- GameObject go = GameObject.Instantiate(Resources.Load<GameObject>("Prefabs/Events/RKEventSystem"));
- go.name = "RKEventSystem";
- go.transform.SetParent(transform);
- }
- InitModuleChangeAudio();
- }
- private void Start()
- {
- InteractorStateChange.OnInteractorTypeChange += OnInteractorTypeChange;
- InteractorStateChange.OnHandDragStatusChanged += OnGestureDragStatusChanged;
- RKHandWatch.OnActiveWatch += OnActiveWatch;
- GesEventInput.OnHandOrHeadHandTypeChange += OnHandOrHeadHandTypeChange;
- MouseEventInput.OnActiveMouseModule += OnActiveMouseModule;
- ThreeDofEventInput.OnActiveThreeDofModule += OnActiveThreeDofModule;
- GesEventInput.OnActiveGesModule += OnActiveGesModule;
- ButtonMouseEventInput.OnActiveButtonMouseModule += OnActiveButtonMouseModule;
- TouchPadEventInput.OnActiveTouchPadModule += OnActiveTouchPadModule;
- MouseEventInput.OnReleaseMouseModule += OnReleaseMouseModule;
- ThreeDofEventInput.OnReleaseThreeDofModule += OnReleaseThreeDofModule;
- GesEventInput.OnReleaseGesModule += OnReleaseGesModule;
- ButtonMouseEventInput.OnReleaseButtonMouseModule += OnReleaseButtonMouseModule;
- TouchPadEventInput.OnReleaseTouchPadModule += OnReleaseTouchPadModule;
- GesEventInput.OnTrackedSuccess += OnTrackedSuccess;
- GesEventInput.OnTrackedFailed += OnTrackedFailed;
- GesEventInput.OnHandOrientationUpdate += OnHandOrientationUpdate;
- Initialize();
- }
- private void OnGestureDragStatusChanged(HandType hand, bool dragging)
- {
- if (hand == HandType.LeftHand)
- {
- if (activeModuleStatus.leftHandStatus.handDragging != dragging)
- {
- activeModuleStatus.leftHandStatus.handDragging = dragging;
- stateChanged = true;
- }
- }
- if (hand == HandType.RightHand)
- {
- if (activeModuleStatus.rightHandStatus.handDragging != dragging)
- {
- activeModuleStatus.rightHandStatus.handDragging = dragging;
- stateChanged = true;
- }
- }
- }
- private void OnActiveWatch(HandType hand, bool active)
- {
- if (hand == HandType.LeftHand)
- {
- activeModuleStatus.leftHandStatus.activeWatchType = active ? ActiveWatchType.EnableWatch : ActiveWatchType.DisableWatch;
- stateChanged = true;
- }
- if (hand == HandType.RightHand)
- {
- activeModuleStatus.rightHandStatus.activeWatchType = active ? ActiveWatchType.EnableWatch : ActiveWatchType.DisableWatch;
- stateChanged = true;
- }
- }
- private void OnHandOrientationUpdate(HandType hand, HandOrientation handOrientation)
- {
- if (hand == HandType.LeftHand)
- {
- if (activeModuleStatus.leftHandStatus.handOrientationType != ConvertType(handOrientation) && activeModuleStatus.leftHandStatus.handDragging == false)
- {
- activeModuleStatus.leftHandStatus.handOrientationType = ConvertType(handOrientation);
- stateChanged = true;
- }
- }
- if (hand == HandType.RightHand)
- {
- if (activeModuleStatus.rightHandStatus.handOrientationType != ConvertType(handOrientation) && activeModuleStatus.rightHandStatus.handDragging == false)
- {
- activeModuleStatus.rightHandStatus.handOrientationType = ConvertType(handOrientation);
- stateChanged = true;
- }
- }
- }
- private void OnTrackedFailed(HandType hand)
- {
- if (hand == HandType.LeftHand || hand == HandType.None)
- {
- if (activeModuleStatus.leftHandStatus.active == true)
- {
- activeModuleStatus.leftHandStatus.active = false;
- stateChanged = true;
- }
- }
- if (hand == HandType.RightHand || hand == HandType.None)
- {
- if (activeModuleStatus.rightHandStatus.active == true)
- {
- activeModuleStatus.rightHandStatus.active = false;
- stateChanged = true;
- }
- }
- }
- protected override void OnDestroy()
- {
- InteractorStateChange.OnInteractorTypeChange -= OnInteractorTypeChange;
- InteractorStateChange.OnHandDragStatusChanged -= OnGestureDragStatusChanged;
- RKHandWatch.OnActiveWatch -= OnActiveWatch;
- GesEventInput.OnHandOrHeadHandTypeChange -= OnHandOrHeadHandTypeChange;
- MouseEventInput.OnActiveMouseModule -= OnActiveMouseModule;
- ThreeDofEventInput.OnActiveThreeDofModule -= OnActiveThreeDofModule;
- GesEventInput.OnActiveGesModule -= OnActiveGesModule;
- ButtonMouseEventInput.OnActiveButtonMouseModule -= OnActiveButtonMouseModule;
- TouchPadEventInput.OnActiveTouchPadModule -= OnActiveTouchPadModule;
- MouseEventInput.OnReleaseMouseModule -= OnReleaseMouseModule;
- ThreeDofEventInput.OnReleaseThreeDofModule -= OnReleaseThreeDofModule;
- GesEventInput.OnReleaseGesModule -= OnReleaseGesModule;
- ButtonMouseEventInput.OnReleaseButtonMouseModule -= OnReleaseButtonMouseModule;
- TouchPadEventInput.OnReleaseTouchPadModule -= OnReleaseTouchPadModule;
- GesEventInput.OnTrackedSuccess -= OnTrackedSuccess;
- GesEventInput.OnTrackedFailed -= OnTrackedFailed;
- GesEventInput.OnHandOrientationUpdate -= OnHandOrientationUpdate;
- }
- private void OnInteractorTypeChange(HandType hand, InteractorType interactorType)
- {
- if (hand == HandType.LeftHand)
- {
- activeModuleStatus.leftHandStatus.handInteractorType = interactorType == InteractorType.Near ? ActiveHandInteractorType.Near : ActiveHandInteractorType.Far;
- stateChanged = true;
- }
- if (hand == HandType.RightHand)
- {
- activeModuleStatus.rightHandStatus.handInteractorType = interactorType == InteractorType.Near ? ActiveHandInteractorType.Near : ActiveHandInteractorType.Far;
- stateChanged = true;
- }
- }
- private void OnHandOrHeadHandTypeChange(HandOrHeadHandType handOrHeadHandType)
- {
- if (handOrHeadHandType == HandOrHeadHandType.NormalHand)
- {
- activeModuleStatus.headHandType = ActiveHeadHandType.NormalHand;
- stateChanged = true;
- }
- else
- {
- activeModuleStatus.headHandType = ActiveHeadHandType.HeadHand;
- stateChanged = true;
- }
- }
- private void OnActiveMouseModule()
- {
- if (!GetMouseActive())
- {
- activeModuleStatus.moduleType = InputModuleType.Mouse;
- stateChanged = true;
- PlayModuleChangeAudio(activeModuleStatus.moduleType);
- OnModuleActive?.Invoke(InputModuleType.Mouse);
- }
- }
- private void OnActiveThreeDofModule()
- {
- if (!GetThreeDofActive())
- {
- activeModuleStatus.moduleType = InputModuleType.ThreeDof;
- stateChanged = true;
- PlayModuleChangeAudio(activeModuleStatus.moduleType);
- OnModuleActive?.Invoke(InputModuleType.ThreeDof);
- }
- }
- private void OnActiveGesModule()
- {
- if (!GetGesActive())
- {
- activeModuleStatus.moduleType = InputModuleType.Gesture;
- activeModuleStatus.leftHandStatus.handInteractorType = ConvertType(GesEventInput.Instance.GetInteractorType(HandType.LeftHand));
- activeModuleStatus.leftHandStatus.handOrientationType = ConvertType(GesEventInput.Instance.GetHandOrientation(HandType.LeftHand));
- activeModuleStatus.rightHandStatus.handInteractorType = ConvertType(GesEventInput.Instance.GetInteractorType(HandType.RightHand));
- activeModuleStatus.rightHandStatus.handOrientationType = ConvertType(GesEventInput.Instance.GetHandOrientation(HandType.RightHand));
- stateChanged = true;
- PlayModuleChangeAudio(activeModuleStatus.moduleType);
- OnModuleActive?.Invoke(InputModuleType.Gesture);
- }
- }
- private void OnActiveButtonMouseModule()
- {
- if (!GetButtonMouseActive())
- {
- activeModuleStatus.moduleType = InputModuleType.ButtonMouse;
- stateChanged = true;
- PlayModuleChangeAudio(activeModuleStatus.moduleType);
- OnModuleActive?.Invoke(InputModuleType.ButtonMouse);
- }
- }
- private void OnActiveTouchPadModule()
- {
- if (!GetTouchPadActive())
- {
- activeModuleStatus.moduleType = InputModuleType.TouchPad;
- stateChanged = true;
- PlayModuleChangeAudio(activeModuleStatus.moduleType);
- OnModuleActive?.Invoke(InputModuleType.TouchPad);
- }
- }
- private void OnReleaseGesModule()
- {
- if (GetGesActive())
- {
- activeModuleStatus.moduleType = InputModuleType.None;
- stateChanged = true;
- }
- }
- private void OnReleaseThreeDofModule()
- {
- if (GetThreeDofActive())
- {
- activeModuleStatus.moduleType = InputModuleType.None;
- stateChanged = true;
- }
- }
- private void OnReleaseMouseModule()
- {
- if (GetMouseActive())
- {
- activeModuleStatus.moduleType = InputModuleType.None;
- stateChanged = true;
- }
- }
- private void OnReleaseButtonMouseModule()
- {
- if (GetButtonMouseActive())
- {
- activeModuleStatus.moduleType = InputModuleType.None;
- stateChanged = true;
- }
- }
- private void OnReleaseTouchPadModule()
- {
- if (GetTouchPadActive())
- {
- activeModuleStatus.moduleType = InputModuleType.None;
- stateChanged = true;
- }
- }
- private void OnTrackedSuccess(HandType hand)
- {
- if (hand == HandType.LeftHand)
- {
- if (activeModuleStatus.leftHandStatus.active == false)
- {
- activeModuleStatus.leftHandStatus.active = true;
- stateChanged = true;
- }
- }
- if (hand == HandType.RightHand)
- {
- if (activeModuleStatus.rightHandStatus.active == false)
- {
- activeModuleStatus.rightHandStatus.active = true;
- stateChanged = true;
- }
- }
- }
- public void RegisterActive(IInputModuleActive moudleActive)
- {
- this.moduleActives.Add(moudleActive);
- stateChanged = true;
- RKLog.KeyInfo($"====ModuleSwitchManager====: RegisterActive {moudleActive.Go.name},{this.moduleActives.Count}");
- }
- public void UnRegisterActive(IInputModuleActive moudleActive)
- {
- this.moduleActives.Remove(moudleActive);
- RKLog.KeyInfo($"====ModuleSwitchManager====: UnRegisterActive {moudleActive.Go.name},{this.moduleActives.Count}");
- }
- private void SetActiveEnable(IInputModuleActive active, bool enabled)
- {
- if (active.Behaviour != null)
- {
- active.Behaviour.enabled = enabled;
- }
- else
- {
- active.Go.SetActive(enabled);
- OnObjectActive?.Invoke(active, enabled);
- }
- }
- private void Update()
- {
- if (stateChanged)
- {
- RKLog.KeyInfo($"====InputModuleManager==== Current Active Status: {activeModuleStatus}");
- stateChanged = false;
- for (int i = 0; i < moduleActives.Count; i++)
- {
- IInputModuleActive active = moduleActives[i];
- bool enabled = false;
- switch (activeModuleStatus.moduleType)
- {
- case InputModuleType.Mouse:
- if (HasInputModuleType(active.ActiveModuleType, ActiveModuleType.Mouse))
- enabled = HasInputModuleType(active.ActiveModuleType, ActiveModuleType.Mouse);
- break;
- case InputModuleType.ThreeDof:
- if (HasInputModuleType(active.ActiveModuleType, ActiveModuleType.ThreeDof))
- enabled = HasInputModuleType(active.ActiveModuleType, ActiveModuleType.ThreeDof);
- break;
- case InputModuleType.Gesture:
- if (HasInputModuleType(active.ActiveModuleType, ActiveModuleType.Gesture))
- {
- if (JudgeHandLost(active.DisableOnHandLost, activeModuleStatus.leftHandStatus.active) && HasHandType(active.ActiveHandType, ActiveHandType.LeftHand) && HasHandInteractorType(active.ActiveHandInteractorType, activeModuleStatus.leftHandStatus.handInteractorType) && HasHandOrientationType(active.ActiveHandOrientationType, activeModuleStatus.leftHandStatus.handOrientationType) &&
- HasWatchType(active.ActiveWatchType, activeModuleStatus.leftHandStatus.activeWatchType) && HasHeadHandType(active.ActiveHeadHandType, activeModuleStatus.headHandType))
- {
- enabled = true;
- }
- if (JudgeHandLost(active.DisableOnHandLost, activeModuleStatus.rightHandStatus.active) && HasHandType(active.ActiveHandType, ActiveHandType.RightHand) && HasHandInteractorType(active.ActiveHandInteractorType, activeModuleStatus.rightHandStatus.handInteractorType) && HasHandOrientationType(active.ActiveHandOrientationType, activeModuleStatus.rightHandStatus.handOrientationType) &&
- HasWatchType(active.ActiveWatchType, activeModuleStatus.rightHandStatus.activeWatchType) && HasHeadHandType(active.ActiveHeadHandType, activeModuleStatus.headHandType))
- {
- enabled = true;
- }
- }
- break;
- case InputModuleType.ButtonMouse:
- if (HasInputModuleType(active.ActiveModuleType, ActiveModuleType.ButtonMouse))
- enabled = HasInputModuleType(active.ActiveModuleType, ActiveModuleType.ButtonMouse);
- break;
- case InputModuleType.TouchPad:
- if (HasInputModuleType(active.ActiveModuleType, ActiveModuleType.TouchPad))
- enabled = HasInputModuleType(active.ActiveModuleType, ActiveModuleType.TouchPad);
- break;
- default:
- enabled = false;
- break;
- }
- SetActiveEnable(active, enabled);
- }
- }
- if (logText != null)
- {
- logText.text = activeModuleStatus.ToString() + $"\r\n\r\nDragThreshold: {EventSystem.current.pixelDragThreshold}";
- }
- }
- #region Judge Has Type
- private bool HasInputModuleType(ActiveModuleType inType, ActiveModuleType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool HasHandType(ActiveHandType inType, ActiveHandType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool HasHandOrientationType(ActiveHandOrientationType inType, ActiveHandOrientationType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool HasHandInteractorType(ActiveHandInteractorType inType, ActiveHandInteractorType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool HasWatchType(ActiveWatchType inType, ActiveWatchType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool HasHeadHandType(ActiveHeadHandType inType, ActiveHeadHandType targetType)
- {
- return (inType & targetType) == targetType;
- }
- private bool JudgeHandLost(bool disableOnHandLost, bool handLost)
- {
- if (disableOnHandLost == false)
- {
- return true;
- }
- else
- {
- return handLost;
- }
- }
- #endregion
- #region Convert
- private ActiveHandInteractorType ConvertType(InteractorType interactorType)
- {
- switch (interactorType)
- {
- case InteractorType.Far:
- return ActiveHandInteractorType.Far;
- case InteractorType.Near:
- return ActiveHandInteractorType.Near;
- }
- return default(ActiveHandInteractorType);
- }
- private ActiveHandOrientationType ConvertType(HandOrientation handOrientation)
- {
- switch (handOrientation)
- {
- case HandOrientation.Back:
- return ActiveHandOrientationType.Back;
- case HandOrientation.Palm:
- return ActiveHandOrientationType.Palm;
- }
- return default(ActiveHandOrientationType);
- }
- #endregion
- #region PlayAudio
- private AudioSource _audioSource;
- public void InitModuleChangeAudio()
- {
- if (!muteModuleActiveSound)
- {
- AudioClip audioClip = (AudioClip)Resources.Load("Audio/ModuleChangeAudio");
- _audioSource = gameObject.AddComponent<AudioSource>();
- _audioSource.clip = audioClip;
- _audioSource.playOnAwake = false;
- }
- }
- public void PlayModuleChangeAudio(InputModuleType type)
- {
- if (!muteModuleActiveSound)
- {
- _audioSource?.Play();
- }
- }
- #endregion
- }
- }
|