VisionOSInputManager.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using SC.XR.Unity.Module_InputSystem;
  4. using UnityEngine;
  5. using UnityEngine.XR.VisionOS;
  6. using UnityEngine.XR.VisionOS.InputDevices;
  7. public class VisionOSInputManager : MonoBehaviour
  8. {
  9. PointerInput m_PointerInput;
  10. void OnEnable()
  11. {
  12. m_PointerInput ??= new PointerInput();
  13. m_PointerInput.Enable();
  14. }
  15. void OnDisable()
  16. {
  17. m_PointerInput.Disable();
  18. }
  19. void Update()
  20. {
  21. var primaryTouch = m_PointerInput.Default.PrimaryPointer.ReadValue<VisionOSSpatialPointerState>();
  22. var phase = primaryTouch.phase;
  23. var began = phase == VisionOSSpatialPointerPhase.Began;
  24. var ended = phase == VisionOSSpatialPointerPhase.Ended;
  25. var active = began || phase == VisionOSSpatialPointerPhase.Moved;
  26. if (began)
  27. {
  28. API_GSXR_Module_InputSystem_Head.GSXR_Head.inputDataHead.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.DOWN);
  29. Debug.Log("beganbeganbeganbeganbegan");
  30. }
  31. if (ended)
  32. {
  33. API_GSXR_Module_InputSystem_Head.GSXR_Head.inputDataHead.inputKeys.InputDataAddKey(InputKeyCode.Enter, InputKeyState.UP);
  34. Debug.Log("endedendedendedendedendedended");
  35. }
  36. if (active)
  37. {
  38. }
  39. }
  40. }