/// <summary> /// 获取资源包列表 /// </summary> private List <PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters, BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext) { List <PatchBundle> result = new List <PatchBundle>(1000); List <string> buildinTags = buildParameters.Parameters.GetBuildinTags(); var buildMode = buildParameters.Parameters.BuildMode; bool standardBuild = buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild; foreach (var bundleInfo in buildMapContext.BundleInfos) { var bundleName = bundleInfo.BundleName; string filePath = $"{buildParameters.PipelineOutputDirectory}/{bundleName}"; string hash = GetFileHash(filePath, standardBuild); string crc32 = GetFileCRC(filePath, standardBuild); long size = GetFileSize(filePath, standardBuild); string[] tags = buildMapContext.GetBundleTags(bundleName); bool isEncrypted = encryptionContext.IsEncryptFile(bundleName); bool isBuildin = IsBuildinBundle(tags, buildinTags); bool isRawFile = bundleInfo.IsRawFile; // 附加文件扩展名 if (buildParameters.Parameters.AppendFileExtension) { hash += bundleInfo.GetAppendExtension(); } PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc32, size, tags); patchBundle.SetFlagsValue(isEncrypted, isBuildin, isRawFile); result.Add(patchBundle); } return(result); }
/// <summary> /// 获取资源包列表 /// </summary> private List <PatchBundle> GetAllPatchBundle(AssetBundleBuilder.BuildParametersContext buildParameters, TaskGetBuildMap.BuildMapContext buildMapContext, TaskEncryption.EncryptionContext encryptionContext, AssetBundleManifest unityManifest) { List <PatchBundle> result = new List <PatchBundle>(); // 内置标记列表 List <string> buildinTags = buildParameters.Parameters.GetBuildinTags(); // 加载旧补丁清单 PatchManifest oldPatchManifest = null; if (buildParameters.Parameters.IsForceRebuild == false) { oldPatchManifest = AssetBundleBuilderHelper.LoadPatchManifestFile(buildParameters.PipelineOutputDirectory); } string[] allAssetBundles = unityManifest.GetAllAssetBundles(); foreach (var bundleName in allAssetBundles) { string path = $"{buildParameters.PipelineOutputDirectory}/{bundleName}"; string hash = HashUtility.FileMD5(path); string crc = HashUtility.FileCRC32(path); long size = FileUtility.GetFileSize(path); int version = buildParameters.Parameters.BuildVersion; string[] collectAssets = buildMapContext.GetCollectAssetPaths(bundleName); string[] depends = unityManifest.GetDirectDependencies(bundleName); string[] tags = buildMapContext.GetAssetTags(bundleName); bool isEncrypted = encryptionContext.IsEncryptFile(bundleName); bool isBuildin = IsBuildinBundle(tags, buildinTags); // 注意:如果文件没有变化使用旧版本号 if (oldPatchManifest != null && oldPatchManifest.Bundles.TryGetValue(bundleName, out PatchBundle value)) { if (value.Hash == hash) { version = value.Version; } } PatchBundle patchBundle = new PatchBundle(bundleName, hash, crc, size, version, collectAssets, depends, tags); patchBundle.SetFlagsValue(isEncrypted, isBuildin); result.Add(patchBundle); } return(result); }