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()