LiveRTCRoomMain.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using LitJson;
  2. using Newtonsoft.Json.Linq;
  3. using SC.XR.Unity.Module_InputSystem;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using UnityEngine;
  7. using UnityEngine.UI;
  8. using static ScenesManager;
  9. public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>
  10. {
  11. public Button videoOpenBtn;
  12. public Button videoCloseBtn;
  13. public Button audioOpenBtn;
  14. public Button audioCloseBtn;
  15. public Button clearArrowBtn;
  16. public Button leaveRoomBtn;
  17. public GameObject defaultUI;
  18. public Button noBtn;
  19. public Button yesBtn;
  20. public RawImage rtcRawImage;
  21. public ManipulationHandler dragBtn;
  22. private void Start()
  23. {
  24. OnInit();
  25. dragBtn.Target = transform.parent;
  26. }
  27. private void Update()
  28. {
  29. if (RTCRoomManager.Instance.expertView != null)
  30. {
  31. //if (!rtcRawImage.gameObject.activeSelf)
  32. // rtcRawImage.gameObject.SetActive(true);
  33. rtcRawImage.texture = RTCRoomManager.Instance.expertView.VideoView;
  34. }
  35. else
  36. {
  37. //if (rtcRawImage.gameObject.activeSelf)
  38. // rtcRawImage.gameObject.SetActive(false);
  39. }
  40. //if (!XRRGBCamera.Instance.RGBCamTexture.isPlaying)
  41. //{
  42. // // XRRGBCamera.Instance.playCamera(1280, 720);
  43. //}
  44. }
  45. private void OnInit()
  46. {
  47. videoOpenBtn.onClick.AddListener(()=> { SetVideo(true); });
  48. videoCloseBtn.onClick.AddListener(() => { SetVideo(false); });
  49. audioOpenBtn.onClick.AddListener(() => { SetAudio(true); });
  50. audioCloseBtn.onClick.AddListener(() => { SetAudio(false); });
  51. clearArrowBtn.onClick.AddListener(ClearAllArrow);
  52. leaveRoomBtn.onClick.AddListener(() => { SetDefaultUI(true); });
  53. noBtn.onClick.AddListener(() => { SetDefaultUI(false); });
  54. yesBtn.onClick.AddListener(LeaveRoom);
  55. }
  56. public void SetAudio(bool state)
  57. {
  58. GHZRtcManager.Instance.OnMicrophone(state);
  59. audioCloseBtn.gameObject.SetActive(state);
  60. audioOpenBtn.gameObject.SetActive(!state);
  61. }
  62. public void SetVideo(bool state)
  63. {
  64. GHZRtcManager.Instance.OnWebCam(state);
  65. videoCloseBtn.gameObject.SetActive(state);
  66. videoOpenBtn.gameObject.SetActive(!state);
  67. }
  68. public void ClearAllArrow()
  69. {
  70. if (ArrowList.Instance)
  71. {
  72. ArrowList.Instance.DeleteAll();
  73. }
  74. }
  75. public void SetDefaultUI(bool state)
  76. {
  77. defaultUI.SetActive(state);
  78. }
  79. public void LeaveRoom()
  80. {
  81. RTCRoomManager.Instance.LeaveChannel();
  82. RTCMainManager.Instance.CloseRoomMain();
  83. // MQTT 通知 专家退出房间
  84. // JsonData data = new JsonData();
  85. // data["action"] = "ExpertLeaveRoom";
  86. // MQTTManager.Instance.PushMsg(MQTTManager.Instance.front + "room/" + MQTTManager.Instance.roomId, data.ToJson());
  87. if (PopPeerView.Instance)
  88. {
  89. PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
  90. PopPeerView.Instance.list.localPosition = new Vector3(0, 0, 0);
  91. PopPeerView.Instance.list.localEulerAngles = new Vector3(0, 0, 0);
  92. }
  93. if (PopUpInfo.Instance)
  94. {
  95. PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
  96. PopUpInfo.Instance.transform.localPosition = new Vector3(0, 0, 0);
  97. PopUpInfo.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  98. }
  99. ScenesManager.Instance.showWindow(SceneType.ShowOffice);
  100. if (InviteDlg.Instance)
  101. {
  102. InviteDlg.Instance.InvitingUnionIdList.Clear();
  103. }
  104. if (ArrowList.Instance)
  105. {
  106. ArrowList.Instance.DeleteAll();
  107. }
  108. if (RoomFile.Instance)
  109. {
  110. RoomFile.Instance.ClearAllFileItem();
  111. }
  112. if (PrintscreenList.Instance)
  113. {
  114. PrintscreenList.Instance.DeleteAll();
  115. }
  116. if (PopPeerView.Instance)
  117. {
  118. PopPeerView.Instance.DestoryAll();
  119. }
  120. if (PopCall.Instance)
  121. {
  122. // PopCall.Instance.gameObject.SetActive(false);
  123. }
  124. //if (ShowRoom.Instance)
  125. //{
  126. // ShowRoom.Instance.ShowMainScreen();
  127. // ShowRoom.Instance.transform.localPosition = new Vector3(0, 0, 0);
  128. // ShowRoom.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  129. //}
  130. API_GSXR_Slam.GSXR_Reset_Slam();
  131. //// 通知后台 退出房间消息
  132. //StartCoroutine(HttpToolLangChao.Instance.SendHttp(HttpActionLang.rtc_leave, "", message =>
  133. //{
  134. // JObject jobject = JObject.Parse(message);
  135. // if (jobject["code"].ToString() == "200")
  136. // {
  137. // //Debug.LogError($"Message:{message}+finished:{jobject["data"]["finished"]}");
  138. // Debug.Log(HttpActionLang.rtc_leave + " DGJ ====> 请求成功 " + message);
  139. // // RemoteRtc.Instance.FiltrationCamera(true);
  140. // }
  141. // else
  142. // {
  143. // Debug.LogError(HttpActionLang.rtc_leave + " 请求失败 " + message);
  144. // }
  145. //}));
  146. XRRGBCamera.Instance.stopCamera();
  147. }
  148. private void OnEnable()
  149. {
  150. audioCloseBtn.gameObject.SetActive(true);
  151. audioOpenBtn.gameObject.SetActive(false);
  152. videoCloseBtn.gameObject.SetActive(true);
  153. videoOpenBtn.gameObject.SetActive(false);
  154. XRRGBCamera.Instance.playCamera(1280, 720);
  155. }
  156. }