mirror of https://github.com/tuyoogame/YooAsset
parent
26ffb829d0
commit
fdf27cbc1a
|
@ -341,6 +341,14 @@ namespace YooAsset
|
|||
_providers.Remove(provider);
|
||||
}
|
||||
}
|
||||
internal bool CheckBundleCanDestroy(int bundleID)
|
||||
{
|
||||
string bundleName = BundleServices.GetBundleName(bundleID);
|
||||
BundleLoaderBase loader = TryGetAssetBundleLoader(bundleName);
|
||||
if (loader == null)
|
||||
return true;
|
||||
return loader.CanDestroy();
|
||||
}
|
||||
|
||||
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
|
|
|
@ -122,6 +122,15 @@ 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)
|
||||
{
|
||||
|
|
|
@ -143,6 +143,7 @@ namespace YooAsset
|
|||
patchBundle.IsRawFile = _buffer.ReadBool();
|
||||
patchBundle.LoadMethod = _buffer.ReadByte();
|
||||
patchBundle.Tags = _buffer.ReadUTF8Array();
|
||||
patchBundle.ReferenceIDs = _buffer.ReadInt32Array();
|
||||
Manifest.BundleList.Add(patchBundle);
|
||||
|
||||
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
||||
|
|
|
@ -41,7 +41,12 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string[] Tags;
|
||||
|
||||
/// <summary>
|
||||
/// 引用该资源包的ID列表
|
||||
/// </summary>
|
||||
public int[] ReferenceIDs;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 所属的包裹名称
|
||||
/// </summary>
|
||||
|
|
|
@ -220,6 +220,22 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包名称
|
||||
/// </summary>
|
||||
public string GetBundleName(int bundleID)
|
||||
{
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
return patchBundle.BundleName;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Invalid bundle id : {bundleID}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取补丁资源
|
||||
/// </summary>
|
||||
|
|
|
@ -65,6 +65,7 @@ namespace YooAsset
|
|||
buffer.WriteBool(patchBundle.IsRawFile);
|
||||
buffer.WriteByte(patchBundle.LoadMethod);
|
||||
buffer.WriteUTF8Array(patchBundle.Tags);
|
||||
buffer.WriteInt32Array(patchBundle.ReferenceIDs);
|
||||
}
|
||||
|
||||
// 写入文件流
|
||||
|
@ -127,6 +128,7 @@ namespace YooAsset
|
|||
patchBundle.IsRawFile = buffer.ReadBool();
|
||||
patchBundle.LoadMethod = buffer.ReadByte();
|
||||
patchBundle.Tags = buffer.ReadUTF8Array();
|
||||
patchBundle.ReferenceIDs = buffer.ReadInt32Array();
|
||||
manifest.BundleList.Add(patchBundle);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,6 +95,10 @@ namespace YooAsset
|
|||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
string IBundleServices.GetBundleName(int bundleID)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
|
|
@ -330,6 +330,10 @@ namespace YooAsset
|
|||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleServices.GetBundleName(int bundleID)
|
||||
{
|
||||
return _activeManifest.GetBundleName(bundleID);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
|
|
@ -123,6 +123,10 @@ namespace YooAsset
|
|||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleServices.GetBundleName(int bundleID)
|
||||
{
|
||||
return _activeManifest.GetBundleName(bundleID);
|
||||
}
|
||||
bool IBundleServices.IsServicesValid()
|
||||
{
|
||||
return _activeManifest != null;
|
||||
|
|
|
@ -13,6 +13,11 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath);
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包名称
|
||||
/// </summary>
|
||||
string GetBundleName(int bundleID);
|
||||
|
||||
/// <summary>
|
||||
/// 服务接口是否有效
|
||||
/// </summary>
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 清单文件格式版本
|
||||
/// </summary>
|
||||
public const string PatchManifestFileVersion = "1.4.0";
|
||||
public const string PatchManifestFileVersion = "1.4.6";
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
Loading…
Reference in New Issue