From 8fb2cd24233a58aaa2a7225a541dbe2fce23c4b3 Mon Sep 17 00:00:00 2001 From: liutao <821580467@qq.com> Date: Thu, 14 May 2026 13:46:23 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=90=AF=E5=8A=A8=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E3=80=91=E5=A2=9E=E5=8A=A0=E8=AF=A6=E7=BB=86=E9=98=B6=E6=AE=B5?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Code/Scripts/GameWrapper/Main.cs | 36 +++++++++++++------ 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs b/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs index e3bcfb05069..3c276f3d976 100644 --- a/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs +++ b/ProjectNLD/Assets/Code/Scripts/GameWrapper/Main.cs @@ -27,33 +27,43 @@ namespace Gameplay private void _InitGame() { - - Type type = Type.GetType(GAME_TYPE_NAME); + var type = Type.GetType(GAME_TYPE_NAME); if (null == type) { - Debug.LogError($"{GAME_TYPE_NAME} Type found"); + Debug.LogError($"[Main: _InitGame] {GAME_TYPE_NAME} Type found"); return; } + DebugUtil.Log($"[Main: _InitGame] {GAME_TYPE_NAME} Type found, start creating instance"); _game = Activator.CreateInstance(type) as BaseGame; if (_game == null) { - DebugUtil.LogError("PhxhSDK.Main: no game instance created"); + DebugUtil.LogError("[Main: _InitGame] PhxhSDK.Main: no game instance created"); + return; } + DebugUtil.Log($"[Main: _InitGame] {GAME_TYPE_NAME} instance created successfully: {_game.GetType().FullName}"); SDKManager.GetSingleton().Init(); + DebugUtil.Log("[Main: _InitGame] SDKManager:Init 完成"); + _game.Init(); + DebugUtil.Log("[Main: _InitGame] Game:Init 完成"); + _game.Start(); + DebugUtil.Log("[Main: _InitGame] Game:Start 完成"); } - private async void _InitAsync() + private async UniTask _InitAsync() { + DebugUtil.Log("[Main: _InitAsync] 开始异步初始化"); isInited = false; #if USE_YOO await YooAssetHelper.Init(); + DebugUtil.Log("[Main: _InitAsync] 资源系统初始化完成"); #endif isInited = true; _InitGame(); + DebugUtil.Log("[Main: _InitAsync] 游戏初始化完成"); } private void Awake() @@ -69,7 +79,7 @@ namespace Gameplay private async UniTask _DynamicEnableLog() { - + Debug.Log("[Main:_DynamicEnableLog] 开始动态设置日志"); if (InformationShower.Instance != null) { // 先默认关闭 @@ -81,6 +91,8 @@ namespace Gameplay #if DEBUG || DEVELOPMENT_BUILD || UNITY_EDITOR shouldEnableDebug = true; #endif + + Debug.Log("[Main:_DynamicEnableLog] 初始日志开关: " + shouldEnableDebug); if (!shouldEnableDebug) { @@ -88,29 +100,33 @@ namespace Gameplay if (await NetChecker.CheckIsInsideNet()) { shouldEnableDebug = true; + Debug.Log("[Main:_DynamicEnableLog] 检测到内网环境, 强制开启日志"); } } - Debug.Log("[Debug] Debug log enabled: " + shouldEnableDebug); + Debug.Log("[Main:_DynamicEnableLog] 日志开关状态: " + shouldEnableDebug); Debug.unityLogger.logEnabled = shouldEnableDebug; DebugUtil.LogEnable = shouldEnableDebug; + + Debug.Log("[Main:_DynamicEnableLog] 日志开关已设置: " + shouldEnableDebug); // 同步控制FPS显示 if (InformationShower.Instance != null) { InformationShower.Instance.enabled = shouldEnableDebug; + Debug.Log("[Main:_DynamicEnableLog] FPS信息展示组件状态: " + shouldEnableDebug); } } private void Start() { - _DynamicEnableLog(); - + _DynamicEnableLog().Forget(); _lastSecondUpdate = Time.time; _lastTenthSecondUpdate = Time.time; _lastTenSecondsUpdate = Time.time; - _InitAsync(); + + _InitAsync().Forget(); } private void Update()