From 390fb99602dc072a3f75fb141f70a2da30987d5a Mon Sep 17 00:00:00 2001 From: keshaohong <740612340@qq.com> Date: Mon, 6 Jul 2026 00:26:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=AF=E8=83=BD=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/Assets/UI/SceneLoader.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/unity/Assets/UI/SceneLoader.cs b/unity/Assets/UI/SceneLoader.cs index 4445861..a6bf386 100644 --- a/unity/Assets/UI/SceneLoader.cs +++ b/unity/Assets/UI/SceneLoader.cs @@ -48,9 +48,13 @@ namespace GameFramework public void LoadScoringScene() => Load(scoringScene); public void Load(string sceneName) { - if (isLoading) return; + if (isLoading) + { + Debug.LogWarning($"[SceneLoader] 上次加载未完成,强制重置并加载: {sceneName}"); + StopAllCoroutines(); + isLoading = false; + } isLoading = true; - StopAllCoroutines(); StartCoroutine(LoadingCoroutine(sceneName)); } @@ -63,7 +67,16 @@ namespace GameFramework "拖到 SceneLoader 的 transitionImage 字段。"); } + Debug.Log($"[SceneLoader] 开始加载场景: {sceneName}"); var loadingOperation = SceneManager.LoadSceneAsync(sceneName); + + if (loadingOperation == null) + { + Debug.LogError($"[SceneLoader] 场景 '{sceneName}' 加载失败!请检查 Build Settings 中是否包含该场景。"); + isLoading = false; + yield break; + } + loadingOperation.allowSceneActivation = false; if (transitionImage != null) @@ -110,6 +123,7 @@ namespace GameFramework transitionImage.gameObject.SetActive(false); } + Debug.Log($"[SceneLoader] 场景加载完成: {sceneName}"); isLoading = false; } }