update asset system

修复引用链无效的问题。
pull/72/head
hevinci 2023-02-24 12:12:44 +08:00
parent 0232e5adec
commit f8ba0c9753
2 changed files with 20 additions and 18 deletions

View File

@ -341,13 +341,13 @@ namespace YooAsset
_providers.Remove(provider);
}
}
internal bool CheckBundleCanDestroy(int bundleID)
internal bool CheckBundleDestroyed(int bundleID)
{
string bundleName = BundleServices.GetBundleName(bundleID);
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
if (loader == null)
return true;
return loader.CanDestroy();
return loader.IsDestroyed;
}
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)

View File

@ -100,7 +100,18 @@ namespace YooAsset
if (IsDone() == false)
return false;
return RefCount <= 0;
if (RefCount > 0)
return false;
// 检查引用链上的资源包是否已经全部销毁
// 注意:互相引用的资源包无法卸载!
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
{
if (Impl.CheckBundleDestroyed(bundleID) == false)
return false;
}
return true;
}
/// <summary>
@ -122,25 +133,16 @@ namespace YooAsset
if (RefCount > _providers.Count)
return;
// 条件3检查依赖链上的资源包
// 依赖该资源包的所有资源包可以销毁
// 注意:互相引用的资源包无法卸载!
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
{
if (Impl.CheckBundleCanDestroy(bundleID) == false)
return;
}
// 销毁所有Providers
{
foreach (var provider in _providers)
{
provider.Destroy();
}
// 从列表里移除Providers
Impl.RemoveBundleProviders(_providers);
_providers.Clear();
}
}
/// <summary>