From c865ddc7f2fe7c5a47f8912f51de986fba64466b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Fri, 10 Oct 2025 10:20:02 +0800 Subject: [PATCH] feat #650 --- .../Internal/LoadBundleFileOperation.cs | 26 +++++++++++++++---- .../ResourceManager/ResourceManager.cs | 8 ++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs b/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs index 038a54a7..02bafa8e 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs @@ -180,11 +180,7 @@ namespace YooAsset /// public bool CanDestroyLoader() { - // 注意:正在加载中的任务不可以销毁 - if (_steps == ESteps.LoadBundleFile) - return false; - - if (RefCount > 0) + if (CanReleasableLoader() == false) return false; // YOOASSET_LEGACY_DEPENDENCY @@ -194,14 +190,34 @@ namespace YooAsset { foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs) { +#if YOOASSET_EXPERIMENTAL + if (_resManager.CheckBundleReleasable(bundleID) == false) + return false; +#else if (_resManager.CheckBundleDestroyed(bundleID) == false) return false; +#endif } } return true; } + /// + /// 是否可以释放 + /// + public bool CanReleasableLoader() + { + // 注意:正在加载中的任务不可以销毁 + if (_steps == ESteps.LoadBundleFile) + return false; + + if (RefCount > 0) + return false; + + return true; + } + /// /// 添加附属的资源提供者 /// diff --git a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs index 9eae02af..69cde4fc 100644 --- a/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs +++ b/Assets/YooAsset/Runtime/ResourceManager/ResourceManager.cs @@ -329,6 +329,14 @@ namespace YooAsset return true; return bundleFileLoader.IsDestroyed; } + internal bool CheckBundleReleasable(int bundleID) + { + string bundleName = _bundleQuery.GetMainBundleName(bundleID); + var bundleFileLoader = TryGetBundleFileLoader(bundleName); + if (bundleFileLoader == null) + return true; + return bundleFileLoader.CanReleasableLoader(); + } internal bool HasAnyLoader() { return LoaderDic.Count > 0;