From ed5ae40cb3345dd4e7d5c42dda64ccf53d09b027 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 12 Jul 2023 20:56:11 +0800 Subject: [PATCH] update asset system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复了在销毁Package时,如果存在正在加载的bundle,会导致后续加载该bundle报错的问题。 --- .../Runtime/AssetSystem/AssetSystem.cs | 26 ++----------------- .../Runtime/PackageSystem/ResourcePackage.cs | 2 +- 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs index b293b0e..0f295ae 100644 --- a/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs +++ b/Assets/YooAsset/Runtime/AssetSystem/AssetSystem.cs @@ -79,30 +79,6 @@ namespace YooAsset _isUnloadSafe = true; } - /// - /// 销毁 - /// - public void DestroyAll() - { - foreach (var provider in _providerList) - { - provider.Destroy(); - } - _providerList.Clear(); - _providerDic.Clear(); - - foreach (var loader in _loaderList) - { - loader.Destroy(true); - } - _loaderList.Clear(); - _loaderDic.Clear(); - - ClearSceneHandle(); - DecryptionServices = null; - BundleServices = null; - } - /// /// 资源回收(卸载引用计数为零的资源) /// @@ -149,10 +125,12 @@ namespace YooAsset { foreach (var provider in _providerList) { + provider.WaitForAsyncComplete(); provider.Destroy(); } foreach (var loader in _loaderList) { + loader.WaitForAsyncComplete(); loader.Destroy(true); } diff --git a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs index c234ece..5aba8fe 100644 --- a/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs +++ b/Assets/YooAsset/Runtime/PackageSystem/ResourcePackage.cs @@ -62,7 +62,7 @@ namespace YooAsset if (_assetSystemImpl != null) { - _assetSystemImpl.DestroyAll(); + _assetSystemImpl.ForceUnloadAllAssets(); _assetSystemImpl = null; } }