CVR_InteractableBase.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. namespace ChivaXR.VR
  2. {
  3. using UnityEngine;
  4. #region 按键枚举
  5. public enum CVR_ButtonPressTypes
  6. {
  7. /// <summary>
  8. /// The button is currently being pressed.
  9. /// </summary>
  10. Press,
  11. /// <summary>
  12. /// The button has just been pressed down.
  13. /// </summary>
  14. PressDown,
  15. /// <summary>
  16. /// The button has just been released.
  17. /// </summary>
  18. PressUp,
  19. /// <summary>
  20. /// The button is currently being touched.
  21. /// </summary>
  22. Touch,
  23. /// <summary>
  24. /// The button has just been touched.
  25. /// </summary>
  26. TouchDown,
  27. /// <summary>
  28. /// The button is no longer being touched.
  29. /// </summary>
  30. TouchUp
  31. }
  32. public enum CVR_ButtonTypes
  33. {
  34. /// <summary>
  35. /// Button One on the controller.
  36. /// </summary>
  37. ButtonOne,
  38. /// <summary>
  39. /// Button Two on the controller.
  40. /// </summary>
  41. ButtonTwo,
  42. /// <summary>
  43. /// Grip on the controller.
  44. /// </summary>
  45. Grip,
  46. /// <summary>
  47. /// Grip Hairline on the controller.
  48. /// </summary>
  49. GripHairline,
  50. /// <summary>
  51. /// Start Menu on the controller.
  52. /// </summary>
  53. StartMenu,
  54. /// <summary>
  55. /// Trigger on the controller.
  56. /// </summary>
  57. Trigger,
  58. /// <summary>
  59. /// Trigger Hairline on the controller.
  60. /// </summary>
  61. TriggerHairline,
  62. /// <summary>
  63. /// Touchpad on the controller.
  64. /// </summary>
  65. Touchpad,
  66. /// <summary>
  67. /// Touchpad Two on the controller.
  68. /// </summary>
  69. TouchpadTwo,
  70. /// <summary>
  71. /// Middle Finger on the controller.
  72. /// </summary>
  73. MiddleFinger,
  74. /// <summary>
  75. /// Ring Finger on the controller.
  76. /// </summary>
  77. RingFinger,
  78. /// <summary>
  79. /// Pinky Finger on the controller.
  80. /// </summary>
  81. PinkyFinger
  82. }
  83. /// <summary>
  84. /// Controller hand reference.
  85. /// </summary>
  86. public enum CVR_ControllerHand
  87. {
  88. /// <summary>
  89. /// No hand is assigned.
  90. /// </summary>
  91. None,
  92. /// <summary>
  93. /// The left hand is assigned.
  94. /// </summary>
  95. Left,
  96. /// <summary>
  97. /// The right hand is assigned.
  98. /// </summary>
  99. Right
  100. }
  101. #endregion
  102. /// <summary>
  103. /// CVR交互接口(ChivaVR)
  104. /// </summary>
  105. public interface IVR_Interactable
  106. {
  107. /// <summary>
  108. /// 工具类型
  109. /// </summary>
  110. /// <returns></returns>
  111. CVR_ToolType GetToolType();
  112. /// <summary>
  113. /// 是否处于抓取状态
  114. /// </summary>
  115. /// <returns></returns>
  116. bool CVR_IsGrabbed();
  117. /// <summary>
  118. /// 是否处于使用状态
  119. /// </summary>
  120. /// <returns></returns>
  121. bool CVR_IsUsing();
  122. /// <summary>
  123. /// 断开使用状态
  124. /// </summary>
  125. /// <returns></returns>
  126. void ForceStopUsing();
  127. /// <summary>
  128. /// 获取当前手柄手部类型(左右)
  129. /// </summary>
  130. /// <returns></returns>
  131. CVR_ControllerHand CVR_GetCurrentHand();
  132. /// <summary>
  133. /// 检测手柄按钮状态
  134. /// </summary>
  135. /// <param name="btnType"></param>
  136. /// <param name="pressType"></param>
  137. /// <returns></returns>
  138. bool CVR_CheckButtonState(CVR_ButtonTypes btnType, CVR_ButtonPressTypes pressType);
  139. Vector2 CVR_GetControllerAxis(CVR_ButtonTypes btnType);
  140. /// <summary>
  141. /// 获取当前手部脚本Object
  142. /// </summary>
  143. /// <returns></returns>
  144. GameObject CVR_GetInteractableObject();
  145. /// <summary>
  146. /// 获取当前物体GameObject
  147. /// </summary>
  148. /// <returns></returns>
  149. GameObject CVR_GetCurrentObject();
  150. /// <summary>
  151. /// 获取VR摄像机
  152. /// </summary>
  153. /// <returns></returns>
  154. GameObject CVR_GetHeadsetCamera();
  155. /// <summary>
  156. /// 当前物体被拾取时
  157. /// </summary>
  158. event CVR_InteractableObjectEventHandler CVR_InteractableObjectGrabbed;
  159. /// <summary>
  160. /// 当前物体松手前
  161. /// </summary>
  162. event CVR_InteractableObjectEventHandler CVR_InteractableObjectPreUnGrabbed;
  163. /// <summary>
  164. /// 当前物体点击使用时
  165. /// </summary>
  166. event CVR_InteractableObjectEventHandler CVR_InteractableObjectUsed;
  167. /// <summary>
  168. /// 当前物体退出使用时
  169. /// </summary>
  170. event CVR_InteractableObjectEventHandler CVR_InteractableObjectUnused;
  171. }
  172. public struct CVR_InteractableObjectEventArgs
  173. {
  174. public GameObject interactingObject;
  175. }
  176. /// <summary>
  177. /// Event Payload
  178. /// </summary>
  179. /// <param name="sender">this object</param>
  180. /// <param name="e"><see cref="InteractableObjectEventArgs"/></param>
  181. public delegate void CVR_InteractableObjectEventHandler(object sender, CVR_InteractableObjectEventArgs e);
  182. }