SupportControl.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  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. RTCRoomManager.Instance.isApply = true;
  97. this.GetService<IRTCService>().CreatRoom();
  98. break;
  99. case RTCEnum.Online:
  100. case RTCEnum.ExpertOnline:
  101. case RTCEnum.ConterlOnline:
  102. case RTCEnum.ALLOnline:
  103. RTCRoomManager.Instance.isApply = true;
  104. RTCRoomManager.Instance.OnLocalUserJoined();
  105. break;
  106. default:
  107. break;
  108. }
  109. }
  110. public void LeaveRoom()
  111. {
  112. switch (RTCRoomManager.Instance.rtcState)
  113. {
  114. case RTCEnum.OFF:
  115. case RTCEnum.Online:
  116. RTCRoomManager.Instance.LeaveChannel();
  117. break;
  118. case RTCEnum.ExpertOnline:
  119. break;
  120. case RTCEnum.ConterlOnline:
  121. break;
  122. case RTCEnum.ALLOnline:
  123. break;
  124. default:
  125. break;
  126. }
  127. }
  128. /// <summary>
  129. /// 选择问题
  130. /// </summary>
  131. /// <param name="question"></param>
  132. public void SettingQuest(int question)
  133. {
  134. this.Question = (QuestionEnum)question;
  135. RTCRoomManager.Instance.question = this.Question;
  136. }
  137. private void Init()
  138. {
  139. ShowRtcTrans = new GameObject("ShowRtcTrans").transform;
  140. ShowRtcTrans.position = OpenXRCamera.Instance.head.position + new Vector3(-1, 0, 0);
  141. ShowRtcTrans.localEulerAngles = new Vector3(0, -90, 0);
  142. ShowRtcTrans.SetParent(OpenXRCamera.Instance.head);
  143. }
  144. private void OnEnable()
  145. {
  146. OnReset?.Invoke();
  147. InitPanel(true);
  148. }
  149. private void Update()
  150. {
  151. /*
  152. if (Test) return;
  153. OnReset?.Invoke();
  154. */
  155. }
  156. private void OnDisable()
  157. {
  158. }
  159. private void InitPanel(bool state)
  160. {
  161. questionPanel.SetActive(state);
  162. allotPanel.SetActive(!state);
  163. }
  164. }
  165. public enum QuestionEnum
  166. {
  167. NetWork =1,
  168. Host=2,
  169. Storage=3
  170. }