InputDeviceHandPartDynamicOpenEvent.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. using UnityEngine.EventSystems;
  8. namespace SC.XR.Unity.Module_InputSystem.InputDeviceHand {
  9. public class InputDeviceHandPartDynamicOpenEvent : InputDeviceHandPartEventBase {
  10. public InputDeviceHandPartDynamicOpenEvent(InputDevicePartDispatchEventHand inputDevicePartDispatchEventHand) : base(inputDevicePartDispatchEventHand) {
  11. }
  12. public override void OnSCStart() {
  13. base.OnSCStart();
  14. newEvent = previousEvent = currentEvent = HandEventType.Null;
  15. }
  16. HandEventType newEvent;
  17. protected override void OnUpdateEvent() {
  18. currentEvent = HandEventType.Null;
  19. if (1 == handInfo.iv_extinfo.ges_dynamic[1]) {
  20. newEvent = HandEventType.Dynamic_Open;
  21. } else if (-1 == handInfo.iv_extinfo.ges_dynamic[1]) {
  22. newEvent = HandEventType.Null;
  23. }
  24. if (newEvent != previousEvent) {
  25. previousEvent = newEvent;
  26. currentEvent = newEvent;
  27. }
  28. //if (currentEvent != HandEventType.Null) {
  29. // DebugMy.Log(inputDeviceHandPart.PartType + " Event -----> " + currentEvent, this, true);
  30. //}
  31. }
  32. public override void OnSCDisable() {
  33. if (previousEvent != HandEventType.Null) {
  34. currentEvent = HandEventType.Null;
  35. }
  36. base.OnSCDisable();
  37. }
  38. }
  39. }