hexiaojie 9 luni în urmă
părinte
comite
4d7d876c7f
1 a modificat fișierele cu 27 adăugiri și 4 ștergeri
  1. 27 4
      GameClient/Assets/Game/HotUpdate/UGUI/UGUIManager.cs

+ 27 - 4
GameClient/Assets/Game/HotUpdate/UGUI/UGUIManager.cs

@@ -6,6 +6,7 @@ namespace GFGGame
     public class UGUIManager : SingletonBase<UGUIManager>
     {
         public GameObject desktop;
+
         public void Init()
         {
             Debug.Log($"正在初始化 GetUUIPrefabPath");
@@ -15,7 +16,31 @@ namespace GFGGame
             Debug.Log($"正在初始化 canvas");
             var canvas = handle.InstantiateSync();
             Debug.Log($"正在初始化 desktop");
-            desktop = canvas.transform.Find("Desktop").gameObject;
+            if (canvas == null)
+            {
+                Debug.Log($"正在初始化 canvas is null");
+            }
+
+            var transform = canvas.transform;
+            if (transform == null)
+            {
+                Debug.Log($"正在初始化 transform is null");
+            }
+
+            var findDesktop = transform.Find("Desktop");
+            if (findDesktop == null)
+            {
+                // 打印所有子节点名称辅助调试
+                Debug.LogError($"未找到 Desktop 子节点!当前子节点列表:");
+                foreach (Transform child in canvas.transform)
+                {
+                    Debug.Log(child.name);
+                }
+
+                Debug.Log($"正在初始化 findDesktop is null");
+            }
+
+            desktop = findDesktop.gameObject;
             Debug.Log($"正在初始化 DontDestroyOnLoad");
             GameObject.DontDestroyOnLoad(canvas);
             Debug.Log($"正在初始化 Init end");
@@ -26,12 +51,10 @@ namespace GFGGame
 
         public void Show()
         {
-
         }
 
         public void Hide()
         {
-
         }
     }
-}
+}