From d1776762c712b2f1889656df26b72ebc575b7f49 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 2 Apr 2025 10:15:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9VR=E9=80=82=E9=85=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Application/SceneCtrls/NiuSceneMng.cs | 6 +++--- .../Utilities/LoadScenesAsyncNoPanel.cs | 4 ++-- Assets/_Scripts/UIRoot.cs | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/Assets/_Scripts/Application/SceneCtrls/NiuSceneMng.cs b/Assets/_Scripts/Application/SceneCtrls/NiuSceneMng.cs index 066aa2f..6c51b06 100644 --- a/Assets/_Scripts/Application/SceneCtrls/NiuSceneMng.cs +++ b/Assets/_Scripts/Application/SceneCtrls/NiuSceneMng.cs @@ -93,11 +93,11 @@ namespace ZXK.LouDiXvMuNiu _curTimeLineCtrl = GetComponent(); #if VR - var zStylus = UIRoot.instance.vrRoot.transform.Find("ZStylus").GetComponent(); + var zStylus = UIRoot.Instance.vrRoot.transform.Find("ZStylus").GetComponent(); zStylus.OnObjectEntered.AddListener(VROnEnter); zStylus.OnObjectExited.AddListener(VROnExit); zStylus.OnClick.AddListener(VROnClick); - var zMouse = UIRoot.instance.vrRoot.transform.Find("ZMouse").GetComponent(); + var zMouse = UIRoot.Instance.vrRoot.transform.Find("ZMouse").GetComponent(); zMouse.OnObjectEntered.AddListener(VROnEnter); zMouse.OnObjectExited.AddListener(VROnExit); zMouse.OnClick.AddListener(VROnClick); @@ -1245,7 +1245,7 @@ namespace ZXK.LouDiXvMuNiu public void ChangeCameraPos(Vector3 pos, Vector3 rot) { #if VR - UIRoot.instance.SetCamera(pos, rot); + UIRoot.Instance.SetCamera(pos, rot); #else ///żתλ kinematic.SetPositionAndRotation(pos, Quaternion.Euler(0, rot.y, 0));///תλ diff --git a/Assets/_Scripts/Framework/Utilities/LoadScenesAsyncNoPanel.cs b/Assets/_Scripts/Framework/Utilities/LoadScenesAsyncNoPanel.cs index bf17bbb..73f18be 100644 --- a/Assets/_Scripts/Framework/Utilities/LoadScenesAsyncNoPanel.cs +++ b/Assets/_Scripts/Framework/Utilities/LoadScenesAsyncNoPanel.cs @@ -43,7 +43,7 @@ namespace CG.UTility _loadedCall?.Invoke(); _isLoadScene = false; StopCoroutine("LoadScene"); - UIRoot.instance.GetEventSystem().SetActive(true); + UIRoot.Instance.GetEventSystem().SetActive(true); Framework.UI_Manage.Instance.ClosePanel("LoadingSceenPanel"); } _async.allowSceneActivation = true; @@ -62,7 +62,7 @@ namespace CG.UTility _isLoadScene = true; StartCoroutine("LoadScene", sceneName); Framework.UI_Manage.Instance.ShowPanel("LoadingSceenPanel", System.Type.GetType("CG.Framework.LoadingSceenPanel"), Framework.UIGroup.Tip); - UIRoot.instance.GetEventSystem().SetActive(false); + UIRoot.Instance.GetEventSystem().SetActive(false); } private IEnumerator LoadScene(string sceneName) diff --git a/Assets/_Scripts/UIRoot.cs b/Assets/_Scripts/UIRoot.cs index 8414c32..95dfb59 100644 --- a/Assets/_Scripts/UIRoot.cs +++ b/Assets/_Scripts/UIRoot.cs @@ -1,25 +1,25 @@ +using CG.Framework; using System.Collections; using System.Collections.Generic; using UnityEngine; +using ZXK.LouDiXvMuNiu; -public class UIRoot : MonoBehaviour +public class UIRoot : MonoSingleton { public GameObject pcCanvas; - public GameObject vrRoot; - public static UIRoot instance; + public GameObject vrRoot; Transform vrCamera; - private void Awake() + + protected override void AwakeSelf() { - instance = this; - DontDestroyOnLoad(this); + base.AwakeSelf(); + #if VR - DontDestroyOnLoad(vrRoot); vrRoot.gameObject.SetActive(true); vrCamera = vrRoot.transform.Find("ZFrame"); #else pcCanvas.gameObject.SetActive(true); #endif - } public GameObject GetEventSystem()