123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- using LitJson;
- using Newtonsoft.Json.Linq;
- using SC.XR.Unity.Module_InputSystem;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using static ScenesManager;
- public class LiveRTCRoomMain : MonoSingleton<LiveRTCRoomMain>
- {
- public Button videoOpenBtn;
- public Button videoCloseBtn;
- public Button audioOpenBtn;
- public Button audioCloseBtn;
- public Button clearArrowBtn;
- public Button leaveRoomBtn;
- public GameObject defaultUI;
- public Button noBtn;
- public Button yesBtn;
- public RawImage rtcRawImage;
- public ManipulationHandler dragBtn;
-
- private void Start()
- {
- OnInit();
- dragBtn.Target = transform.parent;
- }
- private void Update()
- {
- if (RTCRoomManager.Instance.expertView != null)
- {
- //if (!rtcRawImage.gameObject.activeSelf)
- // rtcRawImage.gameObject.SetActive(true);
- rtcRawImage.texture = RTCRoomManager.Instance.expertView.VideoView;
- }
- else
- {
- //if (rtcRawImage.gameObject.activeSelf)
- // rtcRawImage.gameObject.SetActive(false);
- }
- //if (!XRRGBCamera.Instance.RGBCamTexture.isPlaying)
- //{
- // // XRRGBCamera.Instance.playCamera(1280, 720);
- //}
- }
- private void OnInit()
- {
- videoOpenBtn.onClick.AddListener(()=> { SetVideo(true); });
- videoCloseBtn.onClick.AddListener(() => { SetVideo(false); });
- audioOpenBtn.onClick.AddListener(() => { SetAudio(true); });
- audioCloseBtn.onClick.AddListener(() => { SetAudio(false); });
- clearArrowBtn.onClick.AddListener(ClearAllArrow);
- leaveRoomBtn.onClick.AddListener(() => { SetDefaultUI(true); });
- noBtn.onClick.AddListener(() => { SetDefaultUI(false); });
- yesBtn.onClick.AddListener(LeaveRoom);
- }
- public void SetAudio(bool state)
- {
- GHZRtcManager.Instance.OnMicrophone(state);
- audioCloseBtn.gameObject.SetActive(state);
- audioOpenBtn.gameObject.SetActive(!state);
- }
- public void SetVideo(bool state)
- {
-
- GHZRtcManager.Instance.OnWebCam(state);
- videoCloseBtn.gameObject.SetActive(state);
- videoOpenBtn.gameObject.SetActive(!state);
- }
- public void ClearAllArrow()
- {
- if (ArrowList.Instance)
- {
- ArrowList.Instance.DeleteAll();
- }
- }
-
- public void SetDefaultUI(bool state)
- {
- defaultUI.SetActive(state);
-
- }
- public void LeaveRoom()
- {
-
- RTCRoomManager.Instance.LeaveChannel();
- RTCMainManager.Instance.CloseRoomMain();
- // MQTT 通知 专家退出房间
- // JsonData data = new JsonData();
- // data["action"] = "ExpertLeaveRoom";
- // MQTTManager.Instance.PushMsg(MQTTManager.Instance.front + "room/" + MQTTManager.Instance.roomId, data.ToJson());
- if (PopPeerView.Instance)
- {
- PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
- PopPeerView.Instance.list.localPosition = new Vector3(0, 0, 0);
- PopPeerView.Instance.list.localEulerAngles = new Vector3(0, 0, 0);
- }
- if (PopUpInfo.Instance)
- {
- PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
- PopUpInfo.Instance.transform.localPosition = new Vector3(0, 0, 0);
- PopUpInfo.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
- }
- ScenesManager.Instance.showWindow(SceneType.ShowOffice);
- if (InviteDlg.Instance)
- {
- InviteDlg.Instance.InvitingUnionIdList.Clear();
- }
- if (ArrowList.Instance)
- {
- ArrowList.Instance.DeleteAll();
- }
- if (RoomFile.Instance)
- {
- RoomFile.Instance.ClearAllFileItem();
- }
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.DeleteAll();
- }
- if (PopPeerView.Instance)
- {
- PopPeerView.Instance.DestoryAll();
- }
- if (PopCall.Instance)
- {
- // PopCall.Instance.gameObject.SetActive(false);
- }
- //if (ShowRoom.Instance)
- //{
- // ShowRoom.Instance.ShowMainScreen();
- // ShowRoom.Instance.transform.localPosition = new Vector3(0, 0, 0);
- // ShowRoom.Instance.transform.localEulerAngles = new Vector3(0, 0, 0);
- //}
- API_GSXR_Slam.GSXR_Reset_Slam();
- //// 通知后台 退出房间消息
- //StartCoroutine(HttpToolLangChao.Instance.SendHttp(HttpActionLang.rtc_leave, "", message =>
- //{
- // JObject jobject = JObject.Parse(message);
- // if (jobject["code"].ToString() == "200")
- // {
- // //Debug.LogError($"Message:{message}+finished:{jobject["data"]["finished"]}");
- // Debug.Log(HttpActionLang.rtc_leave + " DGJ ====> 请求成功 " + message);
- // // RemoteRtc.Instance.FiltrationCamera(true);
- // }
- // else
- // {
- // Debug.LogError(HttpActionLang.rtc_leave + " 请求失败 " + message);
- // }
- //}));
- XRRGBCamera.Instance.stopCamera();
- }
- private void OnEnable()
- {
- audioCloseBtn.gameObject.SetActive(true);
- audioOpenBtn.gameObject.SetActive(false);
- videoCloseBtn.gameObject.SetActive(true);
- videoOpenBtn.gameObject.SetActive(false);
- XRRGBCamera.Instance.playCamera(1280, 720);
- }
- }
|