LiveRTCRoomMain.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. using Blue;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static ScenesManager;
  7. public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>,IController
  8. {
  9. public Button videoOpenBtn;
  10. public Button videoCloseBtn;
  11. public Button audioOpenBtn;
  12. public Button audioCloseBtn;
  13. public Button clearArrowBtn;
  14. public Button leaveRoomBtn;
  15. public GameObject defaultUI;
  16. public Button noBtn;
  17. public Button yesBtn;
  18. public RawImage rtcRawImage;
  19. private void Start()
  20. {
  21. OnInit();
  22. }
  23. private void Update()
  24. {
  25. if (RTCRoomManager.Instance.expertView != null)
  26. {
  27. if (!rtcRawImage.gameObject.activeSelf)
  28. rtcRawImage.gameObject.SetActive(true);
  29. rtcRawImage.texture = RTCRoomManager.Instance.expertView.VideoView;
  30. }
  31. else
  32. {
  33. if (rtcRawImage.gameObject.activeSelf)
  34. rtcRawImage.gameObject.SetActive(false);
  35. }
  36. }
  37. private void OnInit()
  38. {
  39. videoOpenBtn.onClick.AddListener(()=> { SetVideo(false); });
  40. videoCloseBtn.onClick.AddListener(() => { SetVideo(true); });
  41. audioOpenBtn.onClick.AddListener(() => { SetAudio(false); });
  42. audioCloseBtn.onClick.AddListener(() => { SetAudio(true); });
  43. clearArrowBtn.onClick.AddListener(ClearAllArrow);
  44. leaveRoomBtn.onClick.AddListener(() => { SetDefaultUI(true); });
  45. noBtn.onClick.AddListener(() => { SetDefaultUI(false); });
  46. yesBtn.onClick.AddListener(LeaveRoom);
  47. }
  48. public void SetAudio(bool state)
  49. {
  50. GHZRtcManager.Instance.OnMicrophone(state);
  51. audioCloseBtn.gameObject.SetActive(!state);
  52. audioOpenBtn.gameObject.SetActive(state);
  53. }
  54. public void SetVideo(bool state)
  55. {
  56. GHZRtcManager.Instance.OnWebCam(state);
  57. videoCloseBtn.gameObject.SetActive(!state);
  58. videoOpenBtn.gameObject.SetActive(state);
  59. }
  60. public void ClearAllArrow()
  61. {
  62. if (ArrowList.Instance)
  63. {
  64. ArrowList.Instance.DeleteAll();
  65. }
  66. }
  67. public void SetDefaultUI(bool state)
  68. {
  69. defaultUI.SetActive(state);
  70. }
  71. public void LeaveRoom()
  72. {
  73. RTCRoomManager.Instance.LeaveChannel();
  74. if (PopPeerView.Instance)
  75. {
  76. PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
  77. PopPeerView.Instance.list.localPosition = new Vector3(0, 0, 0);
  78. PopPeerView.Instance.list.localEulerAngles = new Vector3(0, 0, 0);
  79. }
  80. if (PopUpInfo.Instance)
  81. {
  82. PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
  83. PopUpInfo.Instance.transform.localPosition = new Vector3(0, 0, 0);
  84. PopUpInfo.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  85. }
  86. ScenesManager.Instance.showWindow(SceneType.ShowChoose);
  87. if (InviteDlg.Instance)
  88. {
  89. InviteDlg.Instance.InvitingUnionIdList.Clear();
  90. }
  91. if (ArrowList.Instance)
  92. {
  93. ArrowList.Instance.DeleteAll();
  94. }
  95. if (RoomFile.Instance)
  96. {
  97. RoomFile.Instance.ClearAllFileItem();
  98. }
  99. if (PrintscreenList.Instance)
  100. {
  101. PrintscreenList.Instance.DeleteAll();
  102. }
  103. if (PopPeerView.Instance)
  104. {
  105. PopPeerView.Instance.DestoryAll();
  106. }
  107. if (PopCall.Instance)
  108. {
  109. PopCall.Instance.gameObject.SetActive(false);
  110. }
  111. if (ShowRoom.Instance)
  112. {
  113. ShowRoom.Instance.ShowMainScreen();
  114. ShowRoom.Instance.transform.localPosition = new Vector3(0, 0, 0);
  115. ShowRoom.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  116. }
  117. API_GSXR_Slam.GSXR_Reset_Slam();
  118. // RemoteRtc.Instance.FiltrationCamera(true);
  119. }
  120. }