InputDeviceHandPartDynamicClickEvent.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 InputDeviceHandPartDynamicClickEvent : InputDeviceHandPartEventBase {
  10. public InputDeviceHandPartDynamicClickEvent(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[0]) {//no action not null
  20. //newEvent = HandEventType.Null;
  21. } else if (0 == handInfo.iv_extinfo.ges_dynamic[0]) {
  22. newEvent = HandEventType.Dynamic_Click_Down;
  23. } else if (1 == handInfo.iv_extinfo.ges_dynamic[0]) {
  24. newEvent = HandEventType.Dynamic_Click;
  25. } else if (2 == handInfo.iv_extinfo.ges_dynamic[0]) {
  26. newEvent = HandEventType.Dynamic_Click_Hold;
  27. } else if (3 == handInfo.iv_extinfo.ges_dynamic[0]) {
  28. newEvent = HandEventType.Dynamic_Click_Up;
  29. }
  30. if (newEvent != previousEvent) {
  31. previousEvent = newEvent;
  32. currentEvent = newEvent;
  33. }
  34. //if (currentEvent != HandEventType.Null) {
  35. // DebugMy.Log(inputDeviceHandPart.PartType + " Event -----> " + currentEvent, this, true);
  36. //}
  37. }
  38. public override void OnSCDisable() {
  39. if (previousEvent != HandEventType.Null) {
  40. currentEvent = HandEventType.Null;
  41. }
  42. base.OnSCDisable();
  43. }
  44. }
  45. }