This commit is contained in:
何冠峰
2025-10-10 10:20:02 +08:00
parent 0bde506aec
commit c865ddc7f2
2 changed files with 29 additions and 5 deletions

View File

@@ -180,11 +180,7 @@ namespace YooAsset
/// </summary> /// </summary>
public bool CanDestroyLoader() public bool CanDestroyLoader()
{ {
// 注意:正在加载中的任务不可以销毁 if (CanReleasableLoader() == false)
if (_steps == ESteps.LoadBundleFile)
return false;
if (RefCount > 0)
return false; return false;
// YOOASSET_LEGACY_DEPENDENCY // YOOASSET_LEGACY_DEPENDENCY
@@ -194,14 +190,34 @@ namespace YooAsset
{ {
foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs) foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs)
{ {
#if YOOASSET_EXPERIMENTAL
if (_resManager.CheckBundleReleasable(bundleID) == false)
return false;
#else
if (_resManager.CheckBundleDestroyed(bundleID) == false) if (_resManager.CheckBundleDestroyed(bundleID) == false)
return false; return false;
#endif
} }
} }
return true; return true;
} }
/// <summary>
/// 是否可以释放
/// </summary>
public bool CanReleasableLoader()
{
// 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.LoadBundleFile)
return false;
if (RefCount > 0)
return false;
return true;
}
/// <summary> /// <summary>
/// 添加附属的资源提供者 /// 添加附属的资源提供者
/// </summary> /// </summary>

View File

@@ -329,6 +329,14 @@ namespace YooAsset
return true; return true;
return bundleFileLoader.IsDestroyed; 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() internal bool HasAnyLoader()
{ {
return LoaderDic.Count > 0; return LoaderDic.Count > 0;