LiveRTCRoomMain.cs 4.3 KB

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