InputDeviceHandPartEventBase.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 HandEventType currentEvent = HandEventType.Null;
  34. protected HandEventType previousEvent = HandEventType.Null;
  35. /// <summary>
  36. /// 模板模式
  37. /// </summary>
  38. public override void OnSCLateUpdate() {
  39. base.OnSCLateUpdate();
  40. OnUpdateEvent();
  41. DispatchEventDelegate();
  42. DispatchEventTarget();
  43. }
  44. /// <summary>
  45. /// 派发Event到委托
  46. /// </summary>
  47. protected override void DispatchEventDelegate() {
  48. if(eventDelegate == null || currentEvent == HandEventType.Null) {
  49. return;
  50. }
  51. //DebugMy.Log(inputDeviceHandPart.PartType+" DispatchEventDelegate -----> " + currentEvent , this);
  52. eventDelegate(inputDeviceHandPart, currentEvent);
  53. }
  54. protected override void DispatchEventTarget() {
  55. }
  56. }
  57. }