SupportControl.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using Blue;
  4. using TMPro;
  5. using UnityEngine.Events;
  6. using Newtonsoft.Json;
  7. using LitJson;
  8. using Newtonsoft.Json.Linq;
  9. public class SupportControl : AbstractController
  10. {
  11. public bool Test = false;
  12. [SerializeField] private Button Titile_Btn;
  13. [SerializeField] private Toggle ShowHide_Toggle;
  14. [SerializeField] private Button UserList_Btn;
  15. [SerializeField] private Button ShowRtcHistory_Btn;
  16. private Transform ShowRtcTrans;
  17. private FontStyle FontStyleB = FontStyle.Bold;
  18. private FontStyle FontStyleN = FontStyle.Normal;
  19. [SerializeField] private TextMeshProUGUI UserList_Text;
  20. [SerializeField] private TextMeshProUGUI ShowRtcHistory_Text;
  21. private Color colorBlue = new Color32(25,107,255,255);
  22. private Color colorWhite = new Color32(255,255,255,255);
  23. public UnityEvent OnReset = new UnityEvent();
  24. /// <summary>
  25. /// 选择的问题类型
  26. /// </summary>
  27. public QuestionEnum Question;
  28. public GameObject questionPanel;
  29. public GameObject allotPanel;
  30. void Awake()
  31. {
  32. #if UNITY_EDITOR
  33. Test = true;
  34. #endif
  35. Init();
  36. Titile_Btn.onClick.AddListener(() =>
  37. {
  38. transform.position = ShowRtcTrans.position;
  39. Quaternion ang = Quaternion.LookRotation(OpenXRCamera.Instance.head.position - transform.position);
  40. transform.rotation = ang;
  41. transform.localEulerAngles = new Vector3(transform.localEulerAngles.x, transform.localEulerAngles.y + 180f, transform.localEulerAngles.z);
  42. });
  43. UserList_Btn.onClick.AddListener(()=>
  44. {
  45. UserList_Text.fontStyle = (FontStyles)FontStyleB;
  46. ShowRtcHistory_Text.fontStyle = (FontStyles)FontStyleN;
  47. UserList_Text.color = colorBlue;
  48. ShowRtcHistory_Text.color = Color.white;
  49. });
  50. ShowRtcHistory_Btn.onClick.AddListener(()=>
  51. {
  52. UserList_Text.fontStyle = (FontStyles)FontStyleN;
  53. ShowRtcHistory_Text.fontStyle = (FontStyles)FontStyleB;
  54. UserList_Text.color = Color.white;
  55. ShowRtcHistory_Text.color = colorBlue;
  56. });
  57. Question = QuestionEnum.NetWork;
  58. }
  59. public void showRTC()
  60. {
  61. this.GetService<IRTCService>().CreatRoom();
  62. this.GetService<ISignallingService>().GetContacts();
  63. //ShowRTC.Instance.gotoWindow(ScenesManager.SceneType.ShowRTCRoomMain);
  64. }
  65. public void showRTC_Old()
  66. {
  67. LangChaoRTC.Instance.showRTC(0);
  68. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowRoom);
  69. ShowRoom.Instance.gotoWindow(ScenesManager.SceneType.RoomMain);
  70. }
  71. public void Home()
  72. {
  73. if (allotPanel.gameObject.activeSelf)
  74. LeaveRoom();
  75. InitPanel(true);
  76. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose);
  77. }
  78. public void Device()
  79. {
  80. ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowDevice);
  81. }
  82. public void Nav()
  83. {
  84. }
  85. public void History()
  86. {
  87. //ShowRTC.Instance.gotoWindow(ScenesManager.SceneType.ShowRTCHistory);
  88. }
  89. public void ApplyingForAssistance()
  90. {
  91. // 如果在房间 直接申请远程协助
  92. // 否则直接创建
  93. switch (RTCRoomManager.Instance.rtcState)
  94. {
  95. case RTCEnum.OFF:
  96. this.GetService<IRTCService>().CreatRoom();
  97. break;
  98. case RTCEnum.Online:
  99. case RTCEnum.ExpertOnline:
  100. case RTCEnum.ConterlOnline:
  101. case RTCEnum.ALLOnline:
  102. RTCRoomManager.Instance.OnLocalUserJoined();
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. public void LeaveRoom()
  109. {
  110. RTCRoomManager.Instance.LeaveChannel();
  111. }
  112. /// <summary>
  113. /// 选择问题
  114. /// </summary>
  115. /// <param name="question"></param>
  116. public void SettingQuest(int question)
  117. {
  118. this.Question = (QuestionEnum)question;
  119. RTCRoomManager.Instance.question = this.Question;
  120. }
  121. private void Init()
  122. {
  123. ShowRtcTrans = new GameObject("ShowRtcTrans").transform;
  124. ShowRtcTrans.position = OpenXRCamera.Instance.head.position + new Vector3(-1, 0, 0);
  125. ShowRtcTrans.localEulerAngles = new Vector3(0, -90, 0);
  126. ShowRtcTrans.SetParent(OpenXRCamera.Instance.head);
  127. }
  128. private void OnEnable()
  129. {
  130. OnReset?.Invoke();
  131. InitPanel(true);
  132. }
  133. private void Update()
  134. {
  135. /*
  136. if (Test) return;
  137. OnReset?.Invoke();
  138. */
  139. }
  140. private void OnDisable()
  141. {
  142. }
  143. private void InitPanel(bool state)
  144. {
  145. questionPanel.SetActive(state);
  146. allotPanel.SetActive(!state);
  147. }
  148. }
  149. public enum QuestionEnum
  150. {
  151. NetWork =1,
  152. Host=2,
  153. Storage=3
  154. }