diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs index ef8c323..191e030 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/BundledSceneProvider.cs @@ -70,11 +70,13 @@ namespace YooAsset // 2. 加载场景 if (Status == EStatus.Loading) { - _asyncOp = SceneManager.LoadSceneAsync(_sceneName, SceneMode); + // 注意:如果场景不存在则返回NULL + _asyncOp = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode); if (_asyncOp != null) { _asyncOp.allowSceneActivation = true; _asyncOp.priority = _priority; + SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); Status = EStatus.Checking; } else @@ -91,7 +93,6 @@ namespace YooAsset { if (_asyncOp.isDone) { - SceneObject = SceneManager.GetSceneByName(_sceneName); if (SceneObject.IsValid() && _activateOnLoad) SceneManager.SetActiveScene(SceneObject); diff --git a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs index d2f1878..7f80d2f 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs @@ -46,6 +46,7 @@ namespace YooAsset { _asyncOp.allowSceneActivation = true; _asyncOp.priority = _priority; + SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); Status = EStatus.Checking; } else @@ -61,8 +62,7 @@ namespace YooAsset if (Status == EStatus.Checking) { if (_asyncOp.isDone) - { - SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); + { if (SceneObject.IsValid() && _activateOnLoad) SceneManager.SetActiveScene(SceneObject);