LiveRTCRoomMain.cs 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. }
  32. private void OnInit()
  33. {
  34. videoOpenBtn.onClick.AddListener(()=> { SetVideo(false); });
  35. videoCloseBtn.onClick.AddListener(() => { SetVideo(true); });
  36. audioOpenBtn.onClick.AddListener(() => { SetAudio(false); });
  37. audioCloseBtn.onClick.AddListener(() => { SetAudio(true); });
  38. clearArrowBtn.onClick.AddListener(ClearAllArrow);
  39. leaveRoomBtn.onClick.AddListener(() => { SetDefaultUI(true); });
  40. noBtn.onClick.AddListener(() => { SetDefaultUI(false); });
  41. yesBtn.onClick.AddListener(LeaveRoom);
  42. }
  43. public void SetAudio(bool state)
  44. {
  45. GHZRtcManager.Instance.OnWebCam(state);
  46. audioCloseBtn.gameObject.SetActive(!state);
  47. audioOpenBtn.gameObject.SetActive(state);
  48. }
  49. public void SetVideo(bool state)
  50. {
  51. GHZRtcManager.Instance.OnMicrophone(state);
  52. videoCloseBtn.gameObject.SetActive(!state);
  53. videoOpenBtn.gameObject.SetActive(state);
  54. }
  55. public void ClearAllArrow()
  56. {
  57. if (ArrowList.Instance)
  58. {
  59. ArrowList.Instance.DeleteAll();
  60. }
  61. }
  62. public void SetDefaultUI(bool state)
  63. {
  64. defaultUI.SetActive(state);
  65. }
  66. public void LeaveRoom()
  67. {
  68. RTCRoomManager.Instance.LeaveChannel();
  69. if (PopPeerView.Instance)
  70. {
  71. PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
  72. PopPeerView.Instance.list.localPosition = new Vector3(0, 0, 0);
  73. PopPeerView.Instance.list.localEulerAngles = new Vector3(0, 0, 0);
  74. }
  75. if (PopUpInfo.Instance)
  76. {
  77. PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
  78. PopUpInfo.Instance.transform.localPosition = new Vector3(0, 0, 0);
  79. PopUpInfo.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  80. }
  81. ScenesManager.Instance.showWindow(SceneType.ShowChoose);
  82. if (InviteDlg.Instance)
  83. {
  84. InviteDlg.Instance.InvitingUnionIdList.Clear();
  85. }
  86. if (ArrowList.Instance)
  87. {
  88. ArrowList.Instance.DeleteAll();
  89. }
  90. if (RoomFile.Instance)
  91. {
  92. RoomFile.Instance.ClearAllFileItem();
  93. }
  94. if (PrintscreenList.Instance)
  95. {
  96. PrintscreenList.Instance.DeleteAll();
  97. }
  98. if (PopPeerView.Instance)
  99. {
  100. PopPeerView.Instance.DestoryAll();
  101. }
  102. if (PopCall.Instance)
  103. {
  104. PopCall.Instance.gameObject.SetActive(false);
  105. }
  106. if (ShowRoom.Instance)
  107. {
  108. ShowRoom.Instance.ShowMainScreen();
  109. ShowRoom.Instance.transform.localPosition = new Vector3(0, 0, 0);
  110. ShowRoom.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
  111. }
  112. API_GSXR_Slam.GSXR_Reset_Slam();
  113. // RemoteRtc.Instance.FiltrationCamera(true);
  114. }
  115. }