123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267 |
- using System;
- using System.Collections.Generic;
- using LitJson;
- using SC.XR.Unity;
- using UnityEngine;
- using static ScenesManager;
- public class ShowRoom : RemoteSingleton<ShowRoom>
- {
- public List<FileConfig> fileConfiglist = new List<FileConfig>();
- 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<SCButton>();
- }
-
- }
- 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);
- }
- }
|