diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs index 2bf3c56..b9fdc84 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/HostPlayModeImpl.cs @@ -249,16 +249,60 @@ namespace YooAsset /// public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain) { - List unpcakList = PatchHelper.GetUnpackListByTags(AppPatchManifest, tags); + List unpcakList = GetUnpackListByTags(tags); var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain); return operation; } + private List GetUnpackListByTags(string[] tags) + { + List downloadList = new List(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); + } + + /// + /// 创建解压器 + /// public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain) { - List unpcakList = PatchHelper.GetUnpackListByAll(AppPatchManifest); + List unpcakList = GetUnpackListByAll(); var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain); return operation; } + private List GetUnpackListByAll() + { + List downloadList = new List(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 ConvertToUnpackList(List unpackList) + { + List result = new List(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) { diff --git a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs index 40e080a..1a06198 100644 --- a/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs +++ b/Assets/YooAsset/Runtime/PatchSystem/PlayMode/OfflinePlayModeImpl.cs @@ -30,22 +30,6 @@ namespace YooAsset return _appPatchManifest.ResourceVersion; } - /// - /// 创建解压器 - /// - public PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int fileUpackingMaxNumber, int failedTryAgain) - { - List unpcakList = PatchHelper.GetUnpackListByTags(_appPatchManifest, tags); - var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain); - return operation; - } - public PatchUnpackerOperation CreatePatchUnpackerByAll(int fileUpackingMaxNumber, int failedTryAgain) - { - List unpcakList = PatchHelper.GetUnpackListByAll(_appPatchManifest); - var operation = new PatchUnpackerOperation(unpcakList, fileUpackingMaxNumber, failedTryAgain); - return operation; - } - // 设置资源清单 internal void SetAppPatchManifest(PatchManifest patchManifest) { diff --git a/Assets/YooAsset/Runtime/Utility/YooHelper.cs b/Assets/YooAsset/Runtime/Utility/YooHelper.cs index deda52f..68f8053 100644 --- a/Assets/YooAsset/Runtime/Utility/YooHelper.cs +++ b/Assets/YooAsset/Runtime/Utility/YooHelper.cs @@ -124,72 +124,6 @@ namespace YooAsset /// internal static class PatchHelper { - /// - /// 获取内置资源解压列表 - /// - public static List GetUnpackListByTags(PatchManifest appPatchManifest, string[] tags) - { - // 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。 - List downloadList = new List(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 GetUnpackListByAll(PatchManifest appPatchManifest) - { - // 注意:离线运行模式也依赖下面逻辑,所以判断沙盒内文件是否存在不能通过缓存系统去验证。 - List downloadList = new List(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 ConvertToUnpackList(List unpackList) - { - List result = new List(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; - } - /// /// 获取资源信息列表 /// diff --git a/Assets/YooAsset/Runtime/YooAssets.cs b/Assets/YooAsset/Runtime/YooAssets.cs index 9b8962d..9a4e0fd 100644 --- a/Assets/YooAsset/Runtime/YooAssets.cs +++ b/Assets/YooAsset/Runtime/YooAssets.cs @@ -91,11 +91,6 @@ namespace YooAsset /// public class HostPlayModeParameters : InitializeParameters { - /// - /// 当缓存池被污染的时候清理缓存池 - /// - public bool ClearCacheWhenDirty; - /// /// 默认的资源服务器下载地址 /// @@ -106,6 +101,11 @@ namespace YooAsset /// public string FallbackHostServer; + /// + /// 当缓存池被污染的时候清理缓存池 + /// + public bool ClearCacheWhenDirty = false; + /// /// 启用断点续传功能的文件大小 /// @@ -847,7 +847,9 @@ namespace YooAsset } else if (_playMode == EPlayMode.OfflinePlayMode) { - return _offlinePlayModeImpl.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain); + List downloadList = new List(); + 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 downloadList = new List(); + var operation = new PatchUnpackerOperation(downloadList, unpackingMaxNumber, failedTryAgain); + return operation; } else if (_playMode == EPlayMode.HostPlayMode) {