修复可能存在的bug
This commit is contained in:
@@ -48,9 +48,13 @@ namespace GameFramework
|
||||
public void LoadScoringScene() => Load(scoringScene);
|
||||
public void Load(string sceneName)
|
||||
{
|
||||
if (isLoading) return;
|
||||
isLoading = true;
|
||||
if (isLoading)
|
||||
{
|
||||
Debug.LogWarning($"[SceneLoader] 上次加载未完成,强制重置并加载: {sceneName}");
|
||||
StopAllCoroutines();
|
||||
isLoading = false;
|
||||
}
|
||||
isLoading = true;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user