API_Module_InputSystem.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using UnityEngine;
  3. using SC.XR.Unity.Module_InputSystem;
  4. [Obsolete("Please Use API_GSXR_Module_InputSystem")]
  5. public class API_Module_InputSystem
  6. {
  7. ///API-No.50
  8. /// <summary>
  9. /// 获取Module_InputSystem的单例
  10. /// </summary>
  11. /// <returns></returns>
  12. public static Module_InputSystem GetInstance() {
  13. return Module_InputSystem.instance;
  14. }
  15. ///API-No.51
  16. /// <summary>
  17. /// Module_InputSystem是否初始化完成
  18. /// </summary>
  19. /// <returns>true 表示初始化完成,反之</returns>
  20. public static bool IsISInitialized() {
  21. if(Module_InputSystem.instance) {
  22. return Module_InputSystem.instance.initialize;
  23. }
  24. return false;
  25. }
  26. ///API-No.52
  27. /// <summary>
  28. /// 设置Module_InputSystem初始化完成时的回调
  29. /// </summary>
  30. /// <param name="action">委托的方法</param>
  31. public static void AddInitializedCallBack(Action action) {
  32. Module_InputSystem.instance.initializeCallBack += action;
  33. }
  34. ///API-No.53
  35. public static void RemoveInitializedCallBack(Action action) {
  36. Module_InputSystem.instance.initializeCallBack -= action;
  37. }
  38. ///API-No.54
  39. /// <summary>
  40. /// 使能某个输入设备,支持的输入设备见InputDeviceType
  41. /// </summary>
  42. /// <param name="inputDevice">输入设备</param>
  43. public static void EnableInputDevice(InputDeviceType inputDevice) {
  44. if(Module_InputSystem.instance) {
  45. Module_InputSystem.instance.SetActiveInputDevice(inputDevice,true);
  46. }
  47. }
  48. ///API-No.55
  49. /// <summary>
  50. /// 关闭某个输入设备,支持的输入设备见InputDeviceType
  51. /// </summary>
  52. /// <param name="inputDevice">输入设备</param>
  53. public static void DisableInputDevice(InputDeviceType inputDevice) {
  54. if(Module_InputSystem.instance) {
  55. Module_InputSystem.instance.SetActiveInputDevice(inputDevice,false);
  56. }
  57. }
  58. ///API-No.56
  59. ///监听某个按键事件方式1
  60. ///usingusing SC.XR.Unity.Module_InputSystem; 然后继承PointerHandlers类并重写需要的方法
  61. ///支持的事件有:
  62. ///OnPointerExit, OnPointerEnter, OnPointerDown,OnPointerClick,OnPointerUp, OnDrag
  63. ///API-No.57
  64. ///监听某个按键事件方式2
  65. ///using SC.XR.Unity.Module_InputSystem; 然后继承PointerDelegate类然后重写对应的事件
  66. ///支持的事件有:
  67. ///KeyUpDelegateUnRegister KeyUpDelegateRegister KeyLongDelegateRegister
  68. ///KeyLongDelegateUnRegister KeyDownDelegateUnRegister KeyDownDelegateRegister
  69. ///API-No.58
  70. /// <summary>
  71. /// 输入设备检测的目标,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  72. /// </summary>
  73. [Obsolete("This method will be removed in the new version, please use other interfaces to obtain")]
  74. public static GameObject Target {
  75. get {
  76. if(API_Module_InputSystem_Head.Head != null) {
  77. return API_Module_InputSystem_Head.HeadHitTarget;
  78. } else if(API_Module_InputSystem_BT3Dof.BTRight != null) {
  79. return API_Module_InputSystem_BT3Dof.BTHitTarget(API_Module_InputSystem_BT3Dof.BTType.Right);
  80. } else if(API_Module_InputSystem_BT3Dof.BTLeft != null) {
  81. return API_Module_InputSystem_BT3Dof.BTHitTarget(API_Module_InputSystem_BT3Dof.BTType.Left);
  82. }else if(API_Module_InputSystem_GGT26Dof.GGTRight != null) {
  83. return API_Module_InputSystem_GGT26Dof.GGTHitTarget(API_Module_InputSystem_GGT26Dof.GGestureType.Right);
  84. } else if(API_Module_InputSystem_GGT26Dof.GGTLeft != null) {
  85. return API_Module_InputSystem_GGT26Dof.GGTHitTarget(API_Module_InputSystem_GGT26Dof.GGestureType.Left);
  86. }
  87. return null;
  88. }
  89. }
  90. ///API-No.59
  91. /// <summary>
  92. /// 输入设备的发射射线起点,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  93. /// </summary>
  94. [Obsolete("This method will be removed in the new version, please use other interfaces to obtain")]
  95. public static GameObject Gazer {
  96. get {
  97. if(API_Module_InputSystem_Head.Head != null) {
  98. return API_Module_InputSystem_Head.Head.detectorBase.pointerBase.gameObject;
  99. } else if(API_Module_InputSystem_BT3Dof.BTRight != null) {
  100. return API_Module_InputSystem_BT3Dof.BTRight.bT3DofDetector.pointerBase.gameObject;
  101. } else if(API_Module_InputSystem_BT3Dof.BTLeft != null) {
  102. return API_Module_InputSystem_BT3Dof.BTLeft.bT3DofDetector.pointerBase.gameObject;
  103. }else if(API_Module_InputSystem_GGT26Dof.GGTRight != null) {
  104. return API_Module_InputSystem_GGT26Dof.GGTRight.detectorBase.pointerBase.gameObject;
  105. } else if(API_Module_InputSystem_GGT26Dof.GGTLeft != null) {
  106. return API_Module_InputSystem_GGT26Dof.GGTLeft.detectorBase.pointerBase.gameObject;
  107. }
  108. return null;
  109. }
  110. }
  111. ///API-No.60
  112. /// <summary>
  113. /// 输入设备的发射射线方向,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  114. /// </summary>
  115. public static Vector3 Normal {
  116. get {
  117. if(Gazer!=null) {
  118. return Gazer.transform.forward;
  119. }
  120. return Vector3.zero;
  121. }
  122. }
  123. ///API-No.61
  124. /// <summary>
  125. /// 输入设备Cursor的位置,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  126. /// </summary>
  127. [Obsolete("This method will be removed in the new version, please use other interfaces to obtain")]
  128. public static Vector3 Position {
  129. get {
  130. if(API_Module_InputSystem_Head.Head != null) {
  131. return API_Module_InputSystem_Head.GetHeadCursor.transform.position;
  132. } else if(API_Module_InputSystem_BT3Dof.BTRight != null) {
  133. return API_Module_InputSystem_BT3Dof.GetBTCursor(API_Module_InputSystem_BT3Dof.BTType.Right).transform.position;
  134. } else if(API_Module_InputSystem_BT3Dof.BTLeft != null) {
  135. return API_Module_InputSystem_BT3Dof.GetBTCursor(API_Module_InputSystem_BT3Dof.BTType.Left).transform.position;
  136. }else if(API_Module_InputSystem_GGT26Dof.GGTRight != null) {
  137. return API_Module_InputSystem_GGT26Dof.GetGGTCursor(API_Module_InputSystem_GGT26Dof.GGestureType.Right).transform.position;
  138. } else if(API_Module_InputSystem_GGT26Dof.GGTLeft != null) {
  139. return API_Module_InputSystem_GGT26Dof.GetGGTCursor(API_Module_InputSystem_GGT26Dof.GGestureType.Left).transform.position;
  140. }
  141. return Vector3.zero;
  142. }
  143. }
  144. ///API-No.62
  145. /// <summary>
  146. /// 获取当前的具体输入设备,优先级为Head/BTRight/BTLeft/GTRight/GTLeft/GGTRight/GGLeft
  147. /// </summary>
  148. [Obsolete("This method will be removed in the new version, please use other interfaces to obtain")]
  149. public static InputDevicePartBase InputDeviceCurrent {
  150. get {
  151. if(API_Module_InputSystem_Head.Head != null) {
  152. return API_Module_InputSystem_Head.Head;
  153. } else if(API_Module_InputSystem_BT3Dof.BTRight != null) {
  154. return API_Module_InputSystem_BT3Dof.BTRight;
  155. } else if(API_Module_InputSystem_BT3Dof.BTLeft != null) {
  156. return API_Module_InputSystem_BT3Dof.BTLeft;
  157. }
  158. return null;
  159. }
  160. }
  161. public static bool InputDeviceStatus(InputDeviceType deviceType) {
  162. if (Module_InputSystem.instance) {
  163. return Module_InputSystem.instance.GetInputDeviceStatus(deviceType);
  164. }
  165. return false;
  166. }
  167. }