using System; using System.Collections.Generic; using LitJson; using SC.XR.Unity; using UnityEngine; using static ScenesManager; public class ShowRoom : RemoteSingleton { public List fileConfiglist = new List(); public SCButton showMainScreenBtn; public override void Awake() { base.Awake(); GameObject showMainScreenBtnObj = Resources.Load("ZhankaiBtn") as GameObject; showMainScreenBtnObj = Instantiate(showMainScreenBtnObj, this.transform); if (showMainScreenBtnObj) { showMainScreenBtn = showMainScreenBtnObj.transform.GetComponent(); } } private void Start() { WSHandler.Office.OnRefuse += Refuse; WSHandler.Office.OnTimeout += TimeoutRefuse; if (showMainScreenBtn) { showMainScreenBtn.onClick.AddListener(ShowMainScreen); } if (ResetVideoPanal.DifferencePosition == Vector3.zero) { Vector3 vthis = transform.position; ResetVideoPanal.DifferencePosition = new Vector3(vthis.x, vthis.y, vthis.z); } } private void Refuse(JsonData data) { string peerId = data["data"]["peerId"].ToString(); string nickName = data["data"]["nickName"].ToString(); PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName+"拒绝了你的邀请"); if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance) { for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--) { if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId) { InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]); } } } RoomOtherUser.Instance.UpdateList(); } private void TimeoutRefuse(JsonData data) { string peerId = data["data"]["peerId"].ToString(); string nickName = data["data"]["nickName"].ToString(); PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName + "无应答"); if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance) { for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--) { if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId) { InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]); } } } RoomOtherUser.Instance.UpdateList(); } public void ShowMainScreen() { if (RoomInfo.Instance) { RoomInfo.Instance.gameObject.SetActive(true); } if (RoomMain.Instance) { RoomMain.Instance.gameObject.SetActive(true); } if (RoomOtherUser.Instance) { RoomOtherUser.Instance.gameObject.SetActive(true); } if (RoomFile.Instance) { RoomFile.Instance.gameObject.SetActive(true); } showMainScreenBtn.gameObject.SetActive(false); } public void HideMainScreen() { if (RoomInfo.Instance) { RoomInfo.Instance.gameObject.SetActive(false); } if (RoomMain.Instance) { RoomMain.Instance.gameObject.SetActive(false); } if (RoomOtherUser.Instance) { RoomOtherUser.Instance.gameObject.SetActive(false); } if (RoomFile.Instance) { RoomFile.Instance.gameObject.SetActive(false); } showMainScreenBtn.gameObject.SetActive(true); } public void ExitRoom() { if (PopPeerView.Instance && PopPublic.Instance && PopPeerView.Instance.list.parent != PopPublic.Instance.transform) { PopPeerView.Instance.list.position = new Vector3(0, 0.9f, 0); PopPeerView.Instance.list.eulerAngles = new Vector3(0, 0, 0); PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform); } if (PopUpInfo.Instance && PopPublic.Instance && PopUpInfo.Instance.transform.parent != PopPublic.Instance.transform) { PopUpInfo.Instance.transform.position = new Vector3(0, 0.9f, 0); PopUpInfo.Instance.transform.eulerAngles = new Vector3(0, 0, 0); PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform); } API_GSXR_Slam.GSXR_Reset_Slam(); if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null) { if (InviteDlg.Instance.InvitingUnionIdList.Count > 0) { InviteDlg.Instance.InvitingUnionIdList.Clear(); } } if (RoomFile.Instance) { RoomFile.Instance.ClearAllFileItem(); } if (ArrowList.Instance) { ArrowList.Instance.DeleteAll(); } if (PrintscreenList.Instance) { PrintscreenList.Instance.DeleteAll(); } if (PopPeerView.Instance) { PopPeerView.Instance.DestoryAll(); } ShowMainScreen(); if (PopCall.Instance) { PopCall.Instance.gameObject.SetActive(false); } transform.position = new Vector3(0, 0.9f, 0); transform.eulerAngles = new Vector3(0, 0, 0); } public void NetErrorExitRoom() { if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null) { if (InviteDlg.Instance.InvitingUnionIdList.Count > 0) { InviteDlg.Instance.InvitingUnionIdList.Clear(); } } if (RoomFile.Instance) { RoomFile.Instance.ClearAllFileItem(); } if (ArrowList.Instance) { ArrowList.Instance.DeleteAll(); } if (PrintscreenList.Instance) { PrintscreenList.Instance.DeleteAll(); } if (PopPeerView.Instance) { PopPeerView.Instance.DestoryAll(); } ShowMainScreen(); if (PopCall.Instance) { PopCall.Instance.gameObject.SetActive(false); } } private void OnDestroy() { WSHandler.Office.OnRefuse -= Refuse; WSHandler.Office.OnTimeout -= TimeoutRefuse; } public override void initShow() { base.initShow(); ScenesManager.Instance.initRoom(); RoomOtherUser.Instance.UpdateList(); window[4].SetActive(false); Reset(); } public void Reset() { RoomFile.SetIsOnFalse?.Invoke(); if (ArrowList.Instance) { ArrowList.Instance.DeleteAll(); } if (PrintscreenList.Instance) { PrintscreenList.Instance.DeleteAll(); } Vector3 pos = OpenXRCamera.Instance.head.position + new Vector3(-1*(OpenXRCamera.Instance.head.right*0.7f).x, 0.9f, (OpenXRCamera.Instance.head.forward * 1f).z); Debug.Log(" pos " + pos); // HttpsSendLog.Instance.SendLog("Reset" ," Pos " +pos.ToString()); transform.position = new Vector3(pos.x, OpenXRCamera.Instance.head.position.y, pos.z); transform.eulerAngles = new Vector3(0, -30 + OpenXRCamera.Instance.head.eulerAngles.y, 0); ShowMainScreen(); PopPeerView.CloseView?.Invoke(); if (RoomFile.Instance) { RoomFile.Instance.ClearAllFilePrefab(); RoomFile.Instance.ResetToggleValue(); } if (RoomInfo.Instance) { RoomInfo.Instance.ResetChatText(); } } public void ResetPosition() { if(transform.GetChild(0).gameObject.activeSelf) ShowMainScreen(); //Debug.LogError("开始设置位置"); // 视频面板-SDK(0)=差,视频面板=SDK+差 // 第一次获取SDKSystem与视频面板的位置,并记录,点击重置按钮设置位置 //Vector3 vSDKSystem = Camera.main.transform.position; //vSDKSystem.y -= 1; // 遂光比较特殊,其他版本不需要 Vector3 vSDKSystem = OpenXRCamera.Instance.head.position; if (DeviceType.type == "Rhinox") vSDKSystem.y -= 1; // 遂光比较特殊,其他版本不需要 transform.position= new Vector3(vSDKSystem.x+ ResetVideoPanal.DifferencePosition.x, vSDKSystem.y+ ResetVideoPanal.DifferencePosition.y, vSDKSystem.z+ ResetVideoPanal.DifferencePosition.z); Vector3 pos = OpenXRCamera.Instance.head.position + new Vector3(-1*(OpenXRCamera.Instance.head.right * 0.7f).x, 0.9f, (OpenXRCamera.Instance.head.forward*1f).z); Debug.Log(" pos " + pos); // HttpsSendLog.Instance.SendLog("Reset" ," Pos " +pos.ToString()); transform.position = new Vector3(pos.x, OpenXRCamera.Instance.head.position.y, pos.z); transform.eulerAngles = new Vector3(0, -30 + OpenXRCamera.Instance.head.eulerAngles.y, 0); } }