FirstScene.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using UnityEngine;
  2. using UnityEngine.SceneManagement;
  3. using Nxr.Internal;
  4. namespace NXR.Samples
  5. {
  6. public class FirstScene : MonoBehaviour
  7. {
  8. public void JumpToGazeModeScene()
  9. {
  10. SceneManager.LoadScene("GazeModeScene");
  11. }
  12. public void JumpToUIScene()
  13. {
  14. SceneManager.LoadScene("UIScene");
  15. }
  16. public void JumpToInputKeyScene()
  17. {
  18. SceneManager.LoadScene("InputKeyScene");
  19. }
  20. public void JumpToSixdofScene()
  21. {
  22. SceneManager.LoadScene("SixdofScene");
  23. }
  24. public void JumpToCustomCtrlScene()
  25. {
  26. SceneManager.LoadScene("CustomCtrlScene");
  27. }
  28. public void JumpToTeleportScene()
  29. {
  30. SceneManager.LoadScene("CameraTeleportScene");
  31. }
  32. public void JumpToDragScene()
  33. {
  34. SceneManager.LoadScene("ControllerDragScene");
  35. }
  36. public void JumpToSystemApi()
  37. {
  38. SceneManager.LoadScene("SystemApi");
  39. }
  40. public void JumpToServiceScene()
  41. {
  42. SceneManager.LoadScene("ServiceScene");
  43. }
  44. public void JumpToCameraScene()
  45. {
  46. SceneManager.LoadScene("CameraScene");
  47. }
  48. public void JumpToRecordScene()
  49. {
  50. SceneManager.LoadScene("RecordScene");
  51. }
  52. public void JumpToMarkerScene()
  53. {
  54. SceneManager.LoadScene("MarkerScene");
  55. }
  56. public void JumpToSlamScene()
  57. {
  58. SceneManager.LoadScene("SlamScene");
  59. }
  60. private GameObject gazeObject;
  61. void OnGazeEvent(GameObject targetObject)
  62. {
  63. gazeObject = targetObject;
  64. // Debug.Log("OnGazeEvent->" + targetObject.name);
  65. }
  66. // Use this for initialization
  67. void Start()
  68. {
  69. NxrOverrideSettings.OnGazeEvent += OnGazeEvent;
  70. }
  71. // Update is called once per frame
  72. void Update()
  73. {
  74. #if UNITY_EDITOR
  75. if (gazeObject != null)
  76. {
  77. Vector3 start = NxrViewer.Instance.GetHead().transform.position;
  78. float zLength = gazeObject.transform.position.z - start.z;
  79. Vector3 vector = NxrViewer.Instance.GetHead().transform.TransformDirection(Vector3.forward);
  80. UnityEngine.Debug.DrawRay(start, vector * zLength, Color.red);
  81. }
  82. #endif
  83. }
  84. private void OnDestroy()
  85. {
  86. NxrOverrideSettings.OnGazeEvent = OnGazeEvent;
  87. Debug.Log("FirstScene.OnDestroy");
  88. }
  89. }
  90. }