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>
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;
}
/// <summary>
/// 是否可以释放
/// </summary>
public bool CanReleasableLoader()
{
// 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.LoadBundleFile)
return false;
if (RefCount > 0)
return false;
return true;
}
/// <summary>
/// 添加附属的资源提供者
/// </summary>

View File

@@ -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;