using Blue; using TMPro; using UnityEngine; using UnityEngine.UI; public class RTCRoomMain : SingletonMonobehaviour, IController { [SerializeField] private TextMeshProUGUI mRoomName_Text; // 房间名 [SerializeField] private TextMeshProUGUI mRoomID_Text; // 房间ID [SerializeField] private TextMeshProUGUI mRoomPeopleCount_Text; // 房间人数 [SerializeField] private Button mVideoOpen_Btn; // 开启视频 [SerializeField] private Button mVideoClose_Btn; // 关闭视频 [SerializeField] private Button mAudioOpen_Btn; // 开启音频 [SerializeField] private Button mAudioClose_Btn; // 关闭音频 [SerializeField] private Button mInvite_Btn; // 邀请用户 [SerializeField] private Button mLeaveRoom; // 离开房间 [SerializeField] private MeshRenderer mBigView_Mesh; [SerializeField] private RoomOtherUserPanel RoomOtherUserPanel_go; public GameObject mRoomOtherUser; public Transform InviteUserPanelPos; public Texture BigView_MeshTexture { set => mBigView_Mesh.material.mainTexture = value; } [SerializeField] private RawImage mRawImage_Raw; public Texture RawImageTexture { set => mRawImage_Raw.texture = value; } private IRTCService mRTCService; void Start() { mRTCService = this.GetService(); mVideoOpen_Btn.onClick.AddListener(VideoOpen); mVideoClose_Btn.onClick.AddListener(VideoClose); mAudioOpen_Btn.onClick.AddListener(AudioOpen); mAudioClose_Btn.onClick.AddListener(AudioClose); mInvite_Btn.onClick.AddListener(Invite); mLeaveRoom.onClick.AddListener(LeaveRoom); } private void OnEnable() { 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); 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); } #region UI事件 private void VideoOpen() { mRawImage_Raw.gameObject.SetActive(true); mRawImage_Raw.texture = XRRGBCamera.Instance.CaptureImage; mRTCService.ActiveVideo(true); } private void VideoClose() { mRawImage_Raw.gameObject.SetActive(false); mRTCService.ActiveVideo(false); } private void AudioOpen() { mRTCService.ActiveAudio(true); } private void AudioClose() { mRTCService.ActiveAudio(false); } private void Invite() { ShowRTC.Instance.window[2].SetActive(true); InviteUserPanel.Instance.TestInitData(); InviteUserPanel.Instance.gameObject.transform.position = RTCRoomMain.Instance.InviteUserPanelPos.position; InviteUserPanel.Instance.gameObject.transform.eulerAngles = RTCRoomMain.Instance.InviteUserPanelPos.eulerAngles; } private void LeaveRoom() { mRTCService.LeaveRoom(); ResetData(); ScenesManager.Instance.showWindow(ScenesManager.SceneType.ShowChoose); } #endregion /// /// 离开房间后清理数据及UI /// private void ResetData() { InviteUserPanel.Instance.Reset(); RoomOtherUserPanel_go.Reset(); } }