SystemFollow.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. /*
  56. API_GSXR_Slam.GSXR_Reset_Slam();
  57. if (ShowRoom.Instance.gameObject.activeSelf)
  58. {
  59. ShowRoom.Instance.Reset();
  60. }
  61. */
  62. if (ShowRoom.Instance.gameObject.activeSelf)
  63. {
  64. ShowRoom.Instance.Reset();
  65. }
  66. //if (ShowRoom.Instance.gameObject.activeSelf)
  67. // {
  68. // ShowRoom.Instance.ResetPosition();
  69. // }
  70. }
  71. public void Swith3DOf()
  72. {
  73. //API_GSXR_Slam.GSXR_Set_TrackMode(TrackMode.Mode_3Dof);
  74. switch3DofBtn.gameObject.SetActive(false);
  75. switch6DofBtn.gameObject.SetActive(true);
  76. }
  77. public void Swith6DOf()
  78. {
  79. //API_GSXR_Slam.GSXR_Set_TrackMode(TrackMode.Mode_6Dof);
  80. switch3DofBtn.gameObject.SetActive(true);
  81. switch6DofBtn.gameObject.SetActive(false);
  82. //API_GSXR_Slam.GSXR_Reset_Slam();
  83. }
  84. private void SwitchAR()
  85. {
  86. switchAR.gameObject.SetActive(false);
  87. switchMR.gameObject.SetActive(true);
  88. if (GameStart.Instance)
  89. {
  90. GameStart.Instance.gameObject.SetActive(false);
  91. }
  92. //if (RemoteRtc.Instance)
  93. //{
  94. // RemoteRtc.Instance.meshRender.gameObject.layer = LayerMask.NameToLayer("Default");
  95. //}
  96. if (GSXRManager.Instance)
  97. {
  98. GSXRManager.Instance.leftCamera.cullingMask = -1;
  99. GSXRManager.Instance.rightCamera.cullingMask = -1;
  100. }
  101. resetSlamBtn.enabled = false;
  102. switch3DofBtn.enabled = false;
  103. switch6DofBtn.enabled = false;
  104. }
  105. private void SwitchMR()
  106. {
  107. switchAR.gameObject.SetActive(true);
  108. switchMR.gameObject.SetActive(false);
  109. if (GameStart.Instance)
  110. {
  111. GameStart.Instance.gameObject.SetActive(true);
  112. }
  113. //if (RemoteRtc.Instance)
  114. //{
  115. // RemoteRtc.Instance.meshRender.gameObject.layer = LayerMask.NameToLayer("fouces");
  116. //}
  117. if (GSXRManager.Instance)
  118. {
  119. GSXRManager.Instance.leftCamera.cullingMask = ~(1 << 9);
  120. GSXRManager.Instance.rightCamera.cullingMask = ~(1 << 9);
  121. }
  122. resetSlamBtn.enabled = true;
  123. switch3DofBtn.enabled = true;
  124. switch6DofBtn.enabled = true;
  125. }
  126. public void SetBlue(Image image)
  127. {
  128. Color color = Color.white;
  129. color.r = 92 / 255f;
  130. color.g = 170 / 255f;
  131. color.b = 248 / 255f;
  132. color.a = 255f / 255f;
  133. image.color = color;
  134. }
  135. public void SetBlack(Image image)
  136. {
  137. image.color = Color.black;
  138. }
  139. }