GestureXRInteractionManager.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using Unity.XR.CoreUtils;
  2. using UnityEngine;
  3. namespace Ximmerse.XR.InputSystems.GazeAndGestureInteraction
  4. {
  5. public class GestureXRInteractionManager : MonoBehaviour
  6. {
  7. #region Property
  8. private GameObject _eyeray;
  9. private CursorManager _cursorManager;
  10. private XROrigin _xrorigin;
  11. public CursorManager CursorManagergo
  12. {
  13. get => _cursorManager;
  14. }
  15. #endregion
  16. private void Start()
  17. {
  18. _eyeray = FindObjectOfType<EyeReticle>().gameObject;
  19. if (GazeAndHandInteractionSystem.instance.EyeRayGO == GazeAndHandInteractionSystem.EyeRayGameobject.Default)
  20. {
  21. if (_eyeray != null)
  22. {
  23. Destroy(_eyeray);
  24. }
  25. if (GazeAndHandInteractionSystem.instance._eyeRay == null)
  26. {
  27. _eyeray = GameObject.Instantiate(Resources.Load("Gesture/Prefabs/Eye Ray")) as GameObject;
  28. _eyeray.name = "Eye Ray";
  29. GazeAndHandInteractionSystem.instance._eyeRay = _eyeray;
  30. _xrorigin = FindObjectOfType<XROrigin>();
  31. _eyeray.transform.parent = _xrorigin.CameraFloorOffsetObject.transform;
  32. _eyeray.transform.localPosition = new Vector3(0, 0, 0);
  33. }
  34. else if (GazeAndHandInteractionSystem.instance._eyeRay != null)
  35. {
  36. _eyeray = GazeAndHandInteractionSystem.instance._eyeRay;
  37. }
  38. }
  39. else
  40. {
  41. if (_eyeray != null && GazeAndHandInteractionSystem.instance._eyeRay == null)
  42. {
  43. GazeAndHandInteractionSystem.instance._eyeRay = _eyeray;
  44. }
  45. else if (_eyeray == null && GazeAndHandInteractionSystem.instance._eyeRay == null)
  46. {
  47. _eyeray = GameObject.Instantiate(Resources.Load("Gesture/Prefabs/Eye Ray")) as GameObject;
  48. _eyeray.name = "Eye Ray";
  49. GazeAndHandInteractionSystem.instance._eyeRay = _eyeray;
  50. _xrorigin = FindObjectOfType<XROrigin>();
  51. _eyeray.transform.parent = _xrorigin.CameraFloorOffsetObject.transform;
  52. _eyeray.transform.localPosition = new Vector3(0, 0, 0);
  53. }
  54. else
  55. {
  56. _eyeray = GazeAndHandInteractionSystem.instance._eyeRay;
  57. }
  58. }
  59. _cursorManager = new GameObject("CursorManager").AddComponent<CursorManager>();
  60. }
  61. }
  62. }