parent
d452c610c1
commit
6471b237ce
|
@ -249,16 +249,60 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain)
|
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);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
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)
|
public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain)
|
||||||
{
|
{
|
||||||
List<BundleInfo> unpcakList = PatchHelper.GetUnpackListByAll(AppPatchManifest);
|
List<BundleInfo> unpcakList = GetUnpackListByAll();
|
||||||
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain);
|
||||||
return operation;
|
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相关
|
// WEB相关
|
||||||
public string GetPatchDownloadMainURL(string fileName)
|
public string GetPatchDownloadMainURL(string fileName)
|
||||||
|
@ -290,6 +334,26 @@ namespace YooAsset
|
||||||
return bundleInfo;
|
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)
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,22 +30,6 @@ namespace YooAsset
|
||||||
return _appPatchManifest.ResourceVersion;
|
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)
|
internal void SetAppPatchManifest(PatchManifest patchManifest)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,72 +124,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static class PatchHelper
|
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>
|
||||||
/// 获取资源信息列表
|
/// 获取资源信息列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -91,11 +91,6 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HostPlayModeParameters : InitializeParameters
|
public class HostPlayModeParameters : InitializeParameters
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 当缓存池被污染的时候清理缓存池
|
|
||||||
/// </summary>
|
|
||||||
public bool ClearCacheWhenDirty;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 默认的资源服务器下载地址
|
/// 默认的资源服务器下载地址
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -106,6 +101,11 @@ namespace YooAsset
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string FallbackHostServer;
|
public string FallbackHostServer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当缓存池被污染的时候清理缓存池
|
||||||
|
/// </summary>
|
||||||
|
public bool ClearCacheWhenDirty = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用断点续传功能的文件大小
|
/// 启用断点续传功能的文件大小
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -847,7 +847,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
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)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
|
@ -875,7 +877,9 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
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)
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue