InputDeviceHandPartEventBase.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using UnityEngine;
  5. namespace SC.XR.Unity.Module_InputSystem.InputDeviceHand {
  6. public abstract class InputDeviceHandPartEventBase : InputDevicePartEventBase {
  7. public InputDevicePartDispatchEventHand inputDevicePartDispatchEventHand;
  8. public InputDeviceHandPartEventBase(InputDevicePartDispatchEventHand inputDevicePartDispatchEventHand) : base(inputDevicePartDispatchEventHand) {
  9. this.inputDevicePartDispatchEventHand = inputDevicePartDispatchEventHand;
  10. inputDeviceHandPart = this.inputDevicePartDispatchEventHand.inputDeviceHandPart;
  11. handInfo = this.inputDevicePartDispatchEventHand.inputDeviceHandPart.inputDataHand.handInfo;
  12. }
  13. protected handInfo handInfo;
  14. protected InputDeviceHandPart inputDeviceHandPart;
  15. ///-----------------------------算法使用的参数-----start
  16. /// <summary>
  17. /// 超过noise算一次有效运动
  18. /// </summary>
  19. protected float noise = 0.016f;
  20. /// <summary>
  21. /// 几次有效运动算一个Event
  22. /// </summary>
  23. protected int effect = 3;
  24. /// <summary>
  25. /// 多久采样一次是否有超过noise的有效运动,0.1f表示0.1s
  26. /// </summary>
  27. protected float samplingTime = 0.05f;
  28. ///-----------------------------算法使用的参数-----End
  29. /// <summary>
  30. /// 当前的Event状态
  31. /// </summary>
  32. public static HandEventDelegate eventDelegate;
  33. public float EventPercent = 0;
  34. public HandEventType currentEvent = HandEventType.Null;
  35. protected HandEventType previousEvent = HandEventType.Null;
  36. public bool eventfromdriver = false;
  37. /// <summary>
  38. /// 派发Event到委托
  39. /// </summary>
  40. protected override void DispatchEventDelegate() {
  41. if(eventDelegate == null || currentEvent == HandEventType.Null) {
  42. return;
  43. }
  44. //DebugMy.Log(inputDeviceHandPart.PartType+" DispatchEventDelegate -----> " + currentEvent , this,true);
  45. eventDelegate(inputDeviceHandPart, currentEvent, EventPercent);
  46. }
  47. protected override void DispatchEventTarget() {
  48. }
  49. }
  50. }