InputDeviceGCPartEventBase.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. namespace SC.XR.Unity.Module_InputSystem.InputDeviceGC {
  8. public abstract class InputDeviceGCPartEventBase : InputDevicePartEventBase {
  9. InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC;
  10. public InputDeviceGCPartEventBase(InputDevicePartDispatchEventGC inputDevicePartDispatchEventGC) : base(inputDevicePartDispatchEventGC) {
  11. this.inputDevicePartDispatchEventGC = inputDevicePartDispatchEventGC;
  12. }
  13. /// <summary>
  14. /// 超过noise算一次有效运动
  15. /// </summary>
  16. protected float noise = 0.016f;
  17. /// <summary>
  18. /// 几次有效运动算一个Event
  19. /// </summary>
  20. protected int effect = 3;
  21. /// <summary>
  22. /// 多久采样一次是否有超过noise的有效运动,0.1f表示0.1s
  23. /// </summary>
  24. protected float samplingTime = 0.05f;
  25. /// <summary>
  26. /// 当前的Event状态
  27. /// </summary>
  28. public static EventDelegate eventDelegate;
  29. /// <summary>
  30. /// 当前的Event状态
  31. /// </summary>
  32. public GCEventType currentEvent = GCEventType.Null;
  33. protected GCEventType previousEvent = GCEventType.Null;
  34. protected override void DispatchEventDelegate() {
  35. if(eventDelegate == null || currentEvent == GCEventType.Null) {
  36. return;
  37. }
  38. //DebugMy.Log(handShankPart.PartType + " DispatchEventDelegate -----> " + currentEvent, this);
  39. eventDelegate(currentEvent, inputDevicePartDispatchEventGC.inputDeviceGCPart);
  40. }
  41. protected override void DispatchEventTarget() {
  42. }
  43. public override void OnSCDisable() {
  44. currentEvent = previousEvent = GCEventType.Null;
  45. base.OnSCDisable();
  46. }
  47. }
  48. }