GazeTest.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using Nxr.Internal;
  2. using UnityEngine;
  3. namespace NXR.Samples
  4. {
  5. public class GazeTest : MonoBehaviour
  6. {
  7. public TextMesh statusText;
  8. // Start is called before the first frame update
  9. void Start()
  10. {
  11. switch (NxrViewer.Instance.HeadControl)
  12. {
  13. case HeadControl.GazeApplication:
  14. statusText.text = "Gaze App";
  15. break;
  16. case HeadControl.GazeSystem:
  17. statusText.text = "Gaze Native";
  18. break;
  19. case HeadControl.Hover:
  20. statusText.text = "Gaze Hover";
  21. break;
  22. case HeadControl.Controller:
  23. statusText.text = "Gaze Controller";
  24. break;
  25. }
  26. }
  27. public void OnGazeEnter(GameObject gameObject)
  28. {
  29. gameObject.GetComponent<Renderer>().material.color = Color.green;
  30. gameObject.GetComponent<Renderer>().material.SetColor("_BaseColor", Color.green);
  31. }
  32. public void OnGazeExit(GameObject gameObject)
  33. {
  34. gameObject.GetComponent<Renderer>().material.color = Color.white;
  35. gameObject.GetComponent<Renderer>().material.SetColor("_BaseColor", Color.white);
  36. }
  37. public void ChangeToApp()
  38. {
  39. if(NxrViewer.Instance.HeadControl == HeadControl.Controller)
  40. {
  41. statusText.text = "Gaze Controller";
  42. return;
  43. }
  44. statusText.text = "Gaze App";
  45. NxrViewer.Instance.HeadControl = HeadControl.GazeApplication;
  46. }
  47. public void ChangeToNative()
  48. {
  49. if (NxrViewer.Instance.HeadControl == HeadControl.Controller)
  50. {
  51. statusText.text = "Gaze Controller";
  52. return;
  53. }
  54. statusText.text = "Gaze Native";
  55. NxrViewer.Instance.HeadControl = HeadControl.GazeSystem;
  56. }
  57. public void ChangeToContrl()
  58. {
  59. if (NxrViewer.Instance.HeadControl == HeadControl.Controller)
  60. {
  61. statusText.text = "Gaze Controller";
  62. return;
  63. }
  64. statusText.text = "Gaze Hover";
  65. NxrViewer.Instance.HeadControl = HeadControl.Hover;
  66. }
  67. }
  68. }