From 1dc434832a97f46ca0a13885768deab411bd3b9a Mon Sep 17 00:00:00 2001 From: hevinci <hevinci@hotmail.com> Date: Mon, 25 Jul 2022 18:31:35 +0800 Subject: [PATCH] Update AssetSystem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了加载多个相同的子场景而无法全部卸载的问题。 --- .../Runtime/AssetSystem/Provider/BundledSceneProvider.cs | 5 +++-- .../Runtime/AssetSystem/Provider/DatabaseSceneProvider.cs | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) 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);