parent
d452c610c1
commit
6471b237ce
|
@ -249,16 +249,60 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags);
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(tags);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetUnpackListByTags(string[] tags)
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in AppPatchManifest.BundleList)
|
||||
{
|
||||
// 如果不是内置资源
|
||||
if (patchBundle.IsBuildin == false)
|
||||
continue;
|
||||
|
||||
// 忽略缓存文件
|
||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||
continue;
|
||||
|
||||
// 查询DLC资源
|
||||
if (patchBundle.HasTag(tags))
|
||||
{
|
||||
downloadList.Add(patchBundle);
|
||||
}
|
||||
}
|
||||
|
||||
return ConvertToUnpackList(downloadList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建解压器
|
||||
/// </summary>
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(AppPatchManifest);
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetUnpackListByAll()
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in AppPatchManifest.BundleList)
|
||||
{
|
||||
// 如果不是内置资源
|
||||
if (patchBundle.IsBuildin == false)
|
||||
continue;
|
||||
|
||||
// 忽略缓存文件
|
||||
if (DownloadSystem.ContainsVerifyFile(patchBundle.Hash))
|
||||
continue;
|
||||
|
||||
downloadList.Add(patchBundle);
|
||||
}
|
||||
|
||||
return ConvertToUnpackList(downloadList);
|
||||
}
|
||||
|
||||
// WEB相关
|
||||
public string GetPatchDownloadMainURL(string fileName)
|
||||
|
@ -290,6 +334,26 @@ namespace YooAsset
|
|||
return bundleInfo;
|
||||
}
|
||||
|
||||
// 解压相关
|
||||
public List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
||||
foreach (var patchBundle in unpackList)
|
||||
{
|
||||
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||
{
|
||||
// 注意:我们把流加载路径指定为远端下载地址
|
||||
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
|
|
|
@ -30,22 +30,6 @@ namespace YooAsset
|
|||
return _appPatchManifest.ResourceVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建解压器
|
||||
/// </summary>
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByTags(_appPatchManifest, tags);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(_appPatchManifest);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 设置资源清单
|
||||
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||
{
|
||||
|
|
|
@ -124,72 +124,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal static class PatchHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取内置资源解压列表
|
||||
/// </summary>
|
||||
public static List<BundleInfo> GetUnpackListByTags(PatchManifest appPatchManifest, string[] tags)
|
||||
{
|
||||
// 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in appPatchManifest.BundleList)
|
||||
{
|
||||
// 如果已经在沙盒内
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||
if (System.IO.File.Exists(filePath))
|
||||
continue;
|
||||
|
||||
// 如果不是内置资源
|
||||
if (patchBundle.IsBuildin == false)
|
||||
continue;
|
||||
|
||||
// 查询DLC资源
|
||||
if (patchBundle.HasTag(tags))
|
||||
{
|
||||
downloadList.Add(patchBundle);
|
||||
}
|
||||
}
|
||||
|
||||
return ConvertToUnpackList(downloadList);
|
||||
}
|
||||
public static List<BundleInfo> GetUnpackListByAll(PatchManifest appPatchManifest)
|
||||
{
|
||||
// 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in appPatchManifest.BundleList)
|
||||
{
|
||||
// 如果已经在沙盒内
|
||||
string filePath = SandboxHelper.MakeCacheFilePath(patchBundle.Hash);
|
||||
if (System.IO.File.Exists(filePath))
|
||||
continue;
|
||||
|
||||
// 如果不是内置资源
|
||||
if (patchBundle.IsBuildin == false)
|
||||
continue;
|
||||
|
||||
downloadList.Add(patchBundle);
|
||||
}
|
||||
|
||||
return ConvertToUnpackList(downloadList);
|
||||
}
|
||||
private static List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
|
||||
foreach (var patchBundle in unpackList)
|
||||
{
|
||||
var bundleInfo = ConvertToUnpackInfo(patchBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private static BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||
{
|
||||
// 注意:我们把流加载路径指定为远端下载地址
|
||||
string streamingPath = PathHelper.MakeStreamingLoadPath(patchBundle.Hash);
|
||||
streamingPath = PathHelper.ConvertToWWWPath(streamingPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, streamingPath, streamingPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
|
|
|
@ -91,11 +91,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public class HostPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 当缓存池被污染的时候清理缓存池
|
||||
/// </summary>
|
||||
public bool ClearCacheWhenDirty;
|
||||
|
||||
/// <summary>
|
||||
/// 默认的资源服务器下载地址
|
||||
/// </summary>
|
||||
|
@ -106,6 +101,11 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string FallbackHostServer;
|
||||
|
||||
/// <summary>
|
||||
/// 当缓存池被污染的时候清理缓存池
|
||||
/// </summary>
|
||||
public bool ClearCacheWhenDirty = false;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传功能的文件大小
|
||||
/// </summary>
|
||||
|
@ -847,7 +847,9 @@ namespace YooAsset
|
|||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
return _offlinePlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
|
@ -875,7 +877,9 @@ namespace YooAsset
|
|||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
return _offlinePlayModeImpl.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue