support legacy dependency mode

YOOASSET_LEGACY_DEPENDENCY
This commit is contained in:
何冠峰
2025-02-19 18:27:23 +08:00
parent d23c0ba715
commit 576b842368
20 changed files with 317 additions and 34 deletions
@@ -153,7 +153,23 @@ namespace YooAsset
if (IsDone == false)
return false;
return RefCount <= 0;
if (RefCount > 0)
return false;
#region YOOASSET_LEGACY_DEPENDENCY
// 检查引用链上的资源包是否已经全部销毁
// 注意:互相引用的资源包无法卸载!
if (LoadBundleInfo.Bundle.ReferenceBundleIDs.Length > 0)
{
foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs)
{
if (_resourceManager.CheckBundleDestroyed(bundleID) == false)
return false;
}
}
#endregion
return true;
}
/// <summary>
@@ -298,6 +298,14 @@ namespace YooAsset
ProviderDic.Remove(provider.ProviderGUID);
}
}
internal bool CheckBundleDestroyed(int bundleID)
{
string bundleName = _bundleQuery.GetMainBundleName(bundleID);
var bundleFileLoader = TryGetBundleFileLoader(bundleName);
if (bundleFileLoader == null)
return true;
return bundleFileLoader.IsDestroyed;
}
internal bool HasAnyLoader()
{
return LoaderDic.Count > 0;