mirror of https://github.com/tuyoogame/YooAsset
parent
26ffb829d0
commit
fdf27cbc1a
|
@ -341,6 +341,14 @@ namespace YooAsset
|
||||||
_providers.Remove(provider);
|
_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)
|
private BundleLoaderBase CreateAssetBundleLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
|
|
|
@ -122,6 +122,15 @@ namespace YooAsset
|
||||||
if (RefCount > _providers.Count)
|
if (RefCount > _providers.Count)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// 条件3:检查依赖链上的资源包
|
||||||
|
// 依赖该资源包的所有资源包可以销毁
|
||||||
|
// 注意:互相引用的资源包无法卸载!
|
||||||
|
foreach (var bundleID in MainBundleInfo.Bundle.ReferenceIDs)
|
||||||
|
{
|
||||||
|
if (Impl.CheckBundleCanDestroy(bundleID) == false)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 销毁所有Providers
|
// 销毁所有Providers
|
||||||
foreach (var provider in _providers)
|
foreach (var provider in _providers)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,6 +143,7 @@ namespace YooAsset
|
||||||
patchBundle.IsRawFile = _buffer.ReadBool();
|
patchBundle.IsRawFile = _buffer.ReadBool();
|
||||||
patchBundle.LoadMethod = _buffer.ReadByte();
|
patchBundle.LoadMethod = _buffer.ReadByte();
|
||||||
patchBundle.Tags = _buffer.ReadUTF8Array();
|
patchBundle.Tags = _buffer.ReadUTF8Array();
|
||||||
|
patchBundle.ReferenceIDs = _buffer.ReadInt32Array();
|
||||||
Manifest.BundleList.Add(patchBundle);
|
Manifest.BundleList.Add(patchBundle);
|
||||||
|
|
||||||
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
||||||
|
|
|
@ -41,6 +41,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] Tags;
|
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>
|
||||||
/// 尝试获取补丁资源
|
/// 尝试获取补丁资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace YooAsset
|
||||||
buffer.WriteBool(patchBundle.IsRawFile);
|
buffer.WriteBool(patchBundle.IsRawFile);
|
||||||
buffer.WriteByte(patchBundle.LoadMethod);
|
buffer.WriteByte(patchBundle.LoadMethod);
|
||||||
buffer.WriteUTF8Array(patchBundle.Tags);
|
buffer.WriteUTF8Array(patchBundle.Tags);
|
||||||
|
buffer.WriteInt32Array(patchBundle.ReferenceIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入文件流
|
// 写入文件流
|
||||||
|
@ -127,6 +128,7 @@ namespace YooAsset
|
||||||
patchBundle.IsRawFile = buffer.ReadBool();
|
patchBundle.IsRawFile = buffer.ReadBool();
|
||||||
patchBundle.LoadMethod = buffer.ReadByte();
|
patchBundle.LoadMethod = buffer.ReadByte();
|
||||||
patchBundle.Tags = buffer.ReadUTF8Array();
|
patchBundle.Tags = buffer.ReadUTF8Array();
|
||||||
|
patchBundle.ReferenceIDs = buffer.ReadInt32Array();
|
||||||
manifest.BundleList.Add(patchBundle);
|
manifest.BundleList.Add(patchBundle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,10 @@ namespace YooAsset
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|
|
@ -330,6 +330,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
return _activeManifest.GetBundleName(bundleID);
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|
|
@ -123,6 +123,10 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
string IBundleServices.GetBundleName(int bundleID)
|
||||||
|
{
|
||||||
|
return _activeManifest.GetBundleName(bundleID);
|
||||||
|
}
|
||||||
bool IBundleServices.IsServicesValid()
|
bool IBundleServices.IsServicesValid()
|
||||||
{
|
{
|
||||||
return _activeManifest != null;
|
return _activeManifest != null;
|
||||||
|
|
|
@ -13,6 +13,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath);
|
BundleInfo[] GetAllDependBundleInfos(AssetInfo assetPath);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源包名称
|
||||||
|
/// </summary>
|
||||||
|
string GetBundleName(int bundleID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 服务接口是否有效
|
/// 服务接口是否有效
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清单文件格式版本
|
/// 清单文件格式版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string PatchManifestFileVersion = "1.4.0";
|
public const string PatchManifestFileVersion = "1.4.6";
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in New Issue