SystemFollow.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using SC.XR.Unity;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. public class SystemFollow : MonoBehaviour {
  9. //private followCamera followcamera;
  10. public SCButton resetSlamBtn;
  11. public SCButton switch3DofBtn;
  12. public SCButton switch6DofBtn;
  13. public SCButton switchAR;
  14. public SCButton switchMR;
  15. public void InitUI()
  16. {
  17. switch3DofBtn.gameObject.SetActive(false);
  18. switch6DofBtn.gameObject.SetActive(false);
  19. switchAR.gameObject.SetActive(false);
  20. switchMR.gameObject.SetActive(false);
  21. this.gameObject.SetActive(false);
  22. }
  23. public void Init()
  24. {
  25. this.gameObject.SetActive(true);
  26. }
  27. public void ResetPattern()
  28. {
  29. if (switchMR.gameObject.activeSelf)
  30. {
  31. SwitchMR();
  32. }
  33. //if (switch3DofBtn.gameObject.activeSelf)
  34. //{
  35. // Swith3DOf();
  36. //}
  37. this.gameObject.SetActive(false);
  38. }
  39. // Use this for initialization
  40. void Start ()
  41. {
  42. resetSlamBtn.onClick.AddListener(ToResetSlam);
  43. switch3DofBtn.onClick.AddListener(Swith3DOf);
  44. switch6DofBtn.onClick.AddListener(Swith6DOf);
  45. switchAR.onClick.AddListener(SwitchAR);
  46. switchMR.onClick.AddListener(SwitchMR);
  47. }
  48. // Update is called once per frame
  49. void Update () {
  50. this.transform.position = OpenXRCamera.Instance.head.position;
  51. this.transform.eulerAngles = new Vector3 (0, OpenXRCamera.Instance.head.eulerAngles.y,0);
  52. }
  53. public void ToResetSlam()
  54. {
  55. API_GSXR_Slam.GSXR_Reset_Slam();
  56. if (ShowRoom.Instance.gameObject.activeSelf)
  57. {
  58. ShowRoom.Instance.Reset();
  59. }
  60. }
  61. public void Swith3DOf()
  62. {
  63. //API_GSXR_Slam.GSXR_Set_TrackMode(TrackMode.Mode_3Dof);
  64. switch3DofBtn.gameObject.SetActive(false);
  65. switch6DofBtn.gameObject.SetActive(true);
  66. }
  67. public void Swith6DOf()
  68. {
  69. //API_GSXR_Slam.GSXR_Set_TrackMode(TrackMode.Mode_6Dof);
  70. switch3DofBtn.gameObject.SetActive(true);
  71. switch6DofBtn.gameObject.SetActive(false);
  72. //API_GSXR_Slam.GSXR_Reset_Slam();
  73. }
  74. private void SwitchAR()
  75. {
  76. switchAR.gameObject.SetActive(false);
  77. switchMR.gameObject.SetActive(true);
  78. if (GameStart.Instance)
  79. {
  80. GameStart.Instance.gameObject.SetActive(false);
  81. }
  82. //if (RemoteRtc.Instance)
  83. //{
  84. // RemoteRtc.Instance.meshRender.gameObject.layer = LayerMask.NameToLayer("Default");
  85. //}
  86. if (GSXRManager.Instance)
  87. {
  88. GSXRManager.Instance.leftCamera.cullingMask = -1;
  89. GSXRManager.Instance.rightCamera.cullingMask = -1;
  90. }
  91. resetSlamBtn.enabled = false;
  92. switch3DofBtn.enabled = false;
  93. switch6DofBtn.enabled = false;
  94. }
  95. private void SwitchMR()
  96. {
  97. switchAR.gameObject.SetActive(true);
  98. switchMR.gameObject.SetActive(false);
  99. if (GameStart.Instance)
  100. {
  101. GameStart.Instance.gameObject.SetActive(true);
  102. }
  103. //if (RemoteRtc.Instance)
  104. //{
  105. // RemoteRtc.Instance.meshRender.gameObject.layer = LayerMask.NameToLayer("fouces");
  106. //}
  107. if (GSXRManager.Instance)
  108. {
  109. GSXRManager.Instance.leftCamera.cullingMask = ~(1 << 9);
  110. GSXRManager.Instance.rightCamera.cullingMask = ~(1 << 9);
  111. }
  112. resetSlamBtn.enabled = true;
  113. switch3DofBtn.enabled = true;
  114. switch6DofBtn.enabled = true;
  115. }
  116. public void SetBlue(Image image)
  117. {
  118. Color color = Color.white;
  119. color.r = 92 / 255f;
  120. color.g = 170 / 255f;
  121. color.b = 248 / 255f;
  122. color.a = 255f / 255f;
  123. image.color = color;
  124. }
  125. public void SetBlack(Image image)
  126. {
  127. image.color = Color.black;
  128. }
  129. }