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; } }