diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs index af615e8..88b82e0 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/AssetBundleBuilder.cs @@ -51,10 +51,10 @@ namespace YooAsset.Editor new TaskCopyRawFile(), //拷贝原生文件 new TaskVerifyBuildResult(), //验证构建结果 new TaskEncryption(), //加密资源文件 - new TaskUpdatePatchInfo(), //更新补丁信息 - new TaskCreatePatchManifest(), //创建清单文件 + new TaskUpdateBundleInfo(), //更新资源包信息 + new TaskCreateManifest(), //创建清单文件 new TaskCreateReport(), //创建报告文件 - new TaskCreatePatchPackage(), //制作补丁包 + new TaskCreatePackage(), //制作包裹 new TaskCopyBuildinFiles(), //拷贝内置文件 }; } @@ -68,10 +68,10 @@ namespace YooAsset.Editor new TaskCopyRawFile(), //拷贝原生文件 new TaskVerifyBuildResult_SBP(), //验证构建结果 new TaskEncryption(), //加密资源文件 - new TaskUpdatePatchInfo(), //更新补丁信息 - new TaskCreatePatchManifest(), //创建清单文件 + new TaskUpdateBundleInfo(), //更新补丁信息 + new TaskCreateManifest(), //创建清单文件 new TaskCreateReport(), //创建报告文件 - new TaskCreatePatchPackage(), //制作补丁包 + new TaskCreatePackage(), //制作补丁包 new TaskCopyBuildinFiles(), //拷贝内置文件 }; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs index 9663de4..b17a96b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs @@ -8,7 +8,7 @@ namespace YooAsset.Editor { public class BuildBundleInfo { - public class BuildPatchInfo + public class InfoWrapper { /// /// 构建内容的哈希值 @@ -18,17 +18,17 @@ namespace YooAsset.Editor /// /// 文件哈希值 /// - public string PatchFileHash { set; get; } + public string FileHash { set; get; } /// /// 文件哈希值 /// - public string PatchFileCRC { set; get; } + public string FileCRC { set; get; } /// /// 文件哈希值 /// - public long PatchFileSize { set; get; } + public long FileSize { set; get; } /// @@ -39,7 +39,7 @@ namespace YooAsset.Editor /// /// 补丁包输出文件路径 /// - public string PatchOutputFilePath { set; get; } + public string PackageOutputFilePath { set; get; } } /// @@ -56,7 +56,7 @@ namespace YooAsset.Editor /// /// 补丁文件信息 /// - public readonly BuildPatchInfo PatchInfo = new BuildPatchInfo(); + public readonly InfoWrapper BundleInfo = new InfoWrapper(); /// /// Bundle文件的加载方法 @@ -159,7 +159,7 @@ namespace YooAsset.Editor /// /// 获取所有写入补丁清单的资源 /// - public BuildAssetInfo[] GetAllPatchAssetInfos() + public BuildAssetInfo[] GetAllBuildAssetInfos() { return BuildinAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); } @@ -178,19 +178,19 @@ namespace YooAsset.Editor } /// - /// 创建PatchBundle类 + /// 创建PackageBundle类 /// - internal PatchBundle CreatePatchBundle() + internal PackageBundle CreatePackageBundle() { - PatchBundle patchBundle = new PatchBundle(); - patchBundle.BundleName = BundleName; - patchBundle.FileHash = PatchInfo.PatchFileHash; - patchBundle.FileCRC = PatchInfo.PatchFileCRC; - patchBundle.FileSize = PatchInfo.PatchFileSize; - patchBundle.IsRawFile = IsRawFile; - patchBundle.LoadMethod = (byte)LoadMethod; - patchBundle.Tags = GetBundleTags(); - return patchBundle; + PackageBundle packageBundle = new PackageBundle(); + packageBundle.BundleName = BundleName; + packageBundle.FileHash = BundleInfo.FileHash; + packageBundle.FileCRC = BundleInfo.FileCRC; + packageBundle.FileSize = BundleInfo.FileSize; + packageBundle.IsRawFile = IsRawFile; + packageBundle.LoadMethod = (byte)LoadMethod; + packageBundle.Tags = GetBundleTags(); + return packageBundle; } } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs index 7070ceb..fcb8a38 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCopyBuildinFiles.cs @@ -12,13 +12,13 @@ namespace YooAsset.Editor void IBuildTask.Run(BuildContext context) { var buildParametersContext = context.GetContextObject(); - var patchManifestContext = context.GetContextObject(); + var manifestContext = context.GetContextObject(); var buildMode = buildParametersContext.Parameters.BuildMode; if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) { if (buildParametersContext.Parameters.CopyBuildinFileOption != ECopyBuildinFileOption.None) { - CopyBuildinFilesToStreaming(buildParametersContext, patchManifestContext); + CopyBuildinFilesToStreaming(buildParametersContext, manifestContext); } } } @@ -26,7 +26,7 @@ namespace YooAsset.Editor /// /// 拷贝首包资源文件 /// - private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, PatchManifestContext patchManifestContext) + private void CopyBuildinFilesToStreaming(BuildParametersContext buildParametersContext, ManifestContext manifestContext) { ECopyBuildinFileOption option = buildParametersContext.Parameters.CopyBuildinFileOption; string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); @@ -35,7 +35,7 @@ namespace YooAsset.Editor string buildPackageVersion = buildParametersContext.Parameters.PackageVersion; // 加载补丁清单 - PatchManifest patchManifest = patchManifestContext.Manifest; + PackageManifest manifest = manifestContext.Manifest; // 清空流目录 if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.ClearAndCopyByTags) @@ -70,10 +70,10 @@ namespace YooAsset.Editor // 拷贝文件列表(所有文件) if (option == ECopyBuildinFileOption.ClearAndCopyAll || option == ECopyBuildinFileOption.OnlyCopyAll) { - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}"; - string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}"; + string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}"; + string destPath = $"{streamingAssetsDirectory}/{packageBundle.FileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } } @@ -82,12 +82,12 @@ namespace YooAsset.Editor if (option == ECopyBuildinFileOption.ClearAndCopyByTags || option == ECopyBuildinFileOption.OnlyCopyByTags) { string[] tags = buildParametersContext.Parameters.CopyBuildinFileTags.Split(';'); - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.HasTag(tags) == false) + if (packageBundle.HasTag(tags) == false) continue; - string sourcePath = $"{packageOutputDirectory}/{patchBundle.FileName}"; - string destPath = $"{streamingAssetsDirectory}/{patchBundle.FileName}"; + string sourcePath = $"{packageOutputDirectory}/{packageBundle.FileName}"; + string destPath = $"{streamingAssetsDirectory}/{packageBundle.FileName}"; EditorTools.CopyFile(sourcePath, destPath, true); } } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs similarity index 59% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs index ea4cae1..d7d9433 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs @@ -8,23 +8,23 @@ using UnityEditor.Build.Pipeline.Interfaces; namespace YooAsset.Editor { - public class PatchManifestContext : IContextObject + public class ManifestContext : IContextObject { - internal PatchManifest Manifest; + internal PackageManifest Manifest; } - [TaskAttribute("创建补丁清单文件")] - public class TaskCreatePatchManifest : IBuildTask + [TaskAttribute("创建清单文件")] + public class TaskCreateManifest : IBuildTask { void IBuildTask.Run(BuildContext context) { - CreatePatchManifestFile(context); + CreateManifestFile(context); } /// /// 创建补丁清单文件到输出目录 /// - private void CreatePatchManifestFile(BuildContext context) + private void CreateManifestFile(BuildContext context) { var buildMapContext = context.GetContextObject(); var buildParametersContext = context.GetContextObject(); @@ -32,14 +32,14 @@ namespace YooAsset.Editor string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); // 创建新补丁清单 - PatchManifest patchManifest = new PatchManifest(); - patchManifest.FileVersion = YooAssetSettings.PatchManifestFileVersion; - patchManifest.EnableAddressable = buildMapContext.EnableAddressable; - patchManifest.OutputNameStyle = (int)buildParameters.OutputNameStyle; - patchManifest.PackageName = buildParameters.PackageName; - patchManifest.PackageVersion = buildParameters.PackageVersion; - patchManifest.BundleList = GetAllPatchBundle(context); - patchManifest.AssetList = GetAllPatchAsset(context, patchManifest); + PackageManifest manifest = new PackageManifest(); + manifest.FileVersion = YooAssetSettings.ManifestFileVersion; + manifest.EnableAddressable = buildMapContext.EnableAddressable; + manifest.OutputNameStyle = (int)buildParameters.OutputNameStyle; + manifest.PackageName = buildParameters.PackageName; + manifest.PackageVersion = buildParameters.PackageVersion; + manifest.BundleList = GetAllPackageBundle(context); + manifest.AssetList = GetAllPackageAsset(context, manifest); // 更新Unity内置资源包的引用关系 if (buildParameters.BuildPipeline == EBuildPipeline.ScriptableBuildPipeline) @@ -47,7 +47,7 @@ namespace YooAsset.Editor if (buildParameters.BuildMode == EBuildMode.IncrementalBuild) { var buildResultContext = context.GetContextObject(); - UpdateBuiltInBundleReference(patchManifest, buildResultContext, buildMapContext.ShadersBundleName); + UpdateBuiltInBundleReference(manifest, buildResultContext, buildMapContext.ShadersBundleName); } } @@ -57,7 +57,7 @@ namespace YooAsset.Editor if (buildParameters.BuildMode == EBuildMode.IncrementalBuild) { var buildResultContext = context.GetContextObject(); - UpdateScriptPipelineReference(patchManifest, buildResultContext); + UpdateScriptPipelineReference(manifest, buildResultContext); } } @@ -67,7 +67,7 @@ namespace YooAsset.Editor if (buildParameters.BuildMode != EBuildMode.SimulateBuild) { var buildResultContext = context.GetContextObject(); - UpdateBuiltinPipelineReference(patchManifest, buildResultContext); + UpdateBuiltinPipelineReference(manifest, buildResultContext); } } @@ -75,7 +75,7 @@ namespace YooAsset.Editor { string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion); string filePath = $"{packageOutputDirectory}/{fileName}"; - PatchManifestTools.SerializeToJson(filePath, patchManifest); + ManifestTools.SerializeToJson(filePath, manifest); BuildLogger.Log($"创建补丁清单文件:{filePath}"); } @@ -84,14 +84,14 @@ namespace YooAsset.Editor { string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion); string filePath = $"{packageOutputDirectory}/{fileName}"; - PatchManifestTools.SerializeToBinary(filePath, patchManifest); + ManifestTools.SerializeToBinary(filePath, manifest); packageHash = HashUtility.FileMD5(filePath); BuildLogger.Log($"创建补丁清单文件:{filePath}"); - PatchManifestContext patchManifestContext = new PatchManifestContext(); + ManifestContext manifestContext = new ManifestContext(); byte[] bytesData = FileUtility.ReadAllBytes(filePath); - patchManifestContext.Manifest = PatchManifestTools.DeserializeFromBinary(bytesData); - context.SetContextObject(patchManifestContext); + manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData); + context.SetContextObject(manifestContext); } // 创建补丁清单哈希文件 @@ -114,15 +114,15 @@ namespace YooAsset.Editor /// /// 获取资源包列表 /// - private List GetAllPatchBundle(BuildContext context) + private List GetAllPackageBundle(BuildContext context) { var buildMapContext = context.GetContextObject(); - List result = new List(1000); + List result = new List(1000); foreach (var bundleInfo in buildMapContext.Collection) { - var patchBundle = bundleInfo.CreatePatchBundle(); - result.Add(patchBundle); + var packageBundle = bundleInfo.CreatePackageBundle(); + result.Add(packageBundle); } return result; } @@ -130,38 +130,38 @@ namespace YooAsset.Editor /// /// 获取资源列表 /// - private List GetAllPatchAsset(BuildContext context, PatchManifest patchManifest) + private List GetAllPackageAsset(BuildContext context, PackageManifest manifest) { var buildMapContext = context.GetContextObject(); - List result = new List(1000); + List result = new List(1000); foreach (var bundleInfo in buildMapContext.Collection) { - var assetInfos = bundleInfo.GetAllPatchAssetInfos(); + var assetInfos = bundleInfo.GetAllBuildAssetInfos(); foreach (var assetInfo in assetInfos) { - PatchAsset patchAsset = new PatchAsset(); + PackageAsset packageAsset = new PackageAsset(); if (buildMapContext.EnableAddressable) - patchAsset.Address = assetInfo.Address; + packageAsset.Address = assetInfo.Address; else - patchAsset.Address = string.Empty; - patchAsset.AssetPath = assetInfo.AssetPath; - patchAsset.AssetTags = assetInfo.AssetTags.ToArray(); - patchAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, patchManifest); - patchAsset.DependIDs = GetAssetBundleDependIDs(patchAsset.BundleID, assetInfo, patchManifest); - result.Add(patchAsset); + packageAsset.Address = string.Empty; + packageAsset.AssetPath = assetInfo.AssetPath; + packageAsset.AssetTags = assetInfo.AssetTags.ToArray(); + packageAsset.BundleID = GetAssetBundleID(assetInfo.BundleName, manifest); + packageAsset.DependIDs = GetAssetBundleDependIDs(packageAsset.BundleID, assetInfo, manifest); + result.Add(packageAsset); } } return result; } - private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PatchManifest patchManifest) + private int[] GetAssetBundleDependIDs(int mainBundleID, BuildAssetInfo assetInfo, PackageManifest manifest) { List result = new List(); foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) { if (dependAssetInfo.HasBundleName()) { - int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, patchManifest); + int bundleID = GetAssetBundleID(dependAssetInfo.BundleName, manifest); if (mainBundleID != bundleID) { if (result.Contains(bundleID) == false) @@ -171,11 +171,11 @@ namespace YooAsset.Editor } return result.ToArray(); } - private int GetAssetBundleID(string bundleName, PatchManifest patchManifest) + private int GetAssetBundleID(string bundleName, PackageManifest manifest) { - for (int index = 0; index < patchManifest.BundleList.Count; index++) + for (int index = 0; index < manifest.BundleList.Count; index++) { - if (patchManifest.BundleList[index].BundleName == bundleName) + if (manifest.BundleList[index].BundleName == bundleName) return index; } throw new Exception($"Not found bundle name : {bundleName}"); @@ -184,7 +184,7 @@ namespace YooAsset.Editor /// /// 更新Unity内置资源包的引用关系 /// - private void UpdateBuiltInBundleReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext, string shadersBunldeName) + private void UpdateBuiltInBundleReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext, string shadersBunldeName) { // 获取所有依赖着色器资源包的资源包列表 List shaderBundleReferenceList = new List(); @@ -199,33 +199,33 @@ namespace YooAsset.Editor return; // 获取着色器资源包索引 - Predicate predicate = new Predicate(s => s.BundleName == shadersBunldeName); - int shaderBundleId = patchManifest.BundleList.FindIndex(predicate); + Predicate predicate = new Predicate(s => s.BundleName == shadersBunldeName); + int shaderBundleId = manifest.BundleList.FindIndex(predicate); if (shaderBundleId == -1) throw new Exception("没有发现着色器资源包!"); // 检测依赖交集并更新依赖ID - foreach (var patchAsset in patchManifest.AssetList) + foreach (var packageAsset in manifest.AssetList) { - List dependBundles = GetPatchAssetAllDependBundles(patchManifest, patchAsset); + List dependBundles = GetPackageAssetAllDependBundles(manifest, packageAsset); List conflictAssetPathList = dependBundles.Intersect(shaderBundleReferenceList).ToList(); if (conflictAssetPathList.Count > 0) { - List newDependIDs = new List(patchAsset.DependIDs); + List newDependIDs = new List(packageAsset.DependIDs); if (newDependIDs.Contains(shaderBundleId) == false) newDependIDs.Add(shaderBundleId); - patchAsset.DependIDs = newDependIDs.ToArray(); + packageAsset.DependIDs = newDependIDs.ToArray(); } } } - private List GetPatchAssetAllDependBundles(PatchManifest patchManifest, PatchAsset patchAsset) + private List GetPackageAssetAllDependBundles(PackageManifest manifest, PackageAsset packageAsset) { List result = new List(); - string mainBundle = patchManifest.BundleList[patchAsset.BundleID].BundleName; + string mainBundle = manifest.BundleList[packageAsset.BundleID].BundleName; result.Add(mainBundle); - foreach (var dependID in patchAsset.DependIDs) + foreach (var dependID in packageAsset.DependIDs) { - string dependBundle = patchManifest.BundleList[dependID].BundleName; + string dependBundle = manifest.BundleList[dependID].BundleName; result.Add(dependBundle); } return result; @@ -235,18 +235,18 @@ namespace YooAsset.Editor private readonly Dictionary _cachedBundleID = new Dictionary(10000); private readonly Dictionary _cachedBundleDepends = new Dictionary(10000); - private void UpdateScriptPipelineReference(PatchManifest patchManifest, TaskBuilding_SBP.BuildResultContext buildResultContext) + private void UpdateScriptPipelineReference(PackageManifest manifest, TaskBuilding_SBP.BuildResultContext buildResultContext) { int progressValue; - int totalCount = patchManifest.BundleList.Count; + int totalCount = manifest.BundleList.Count; // 缓存资源包ID _cachedBundleID.Clear(); progressValue = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest); - _cachedBundleID.Add(patchBundle.BundleName, bundleID); + int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest); + _cachedBundleID.Add(packageBundle.BundleName, bundleID); EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); @@ -254,43 +254,43 @@ namespace YooAsset.Editor // 缓存资源包依赖 _cachedBundleDepends.Clear(); progressValue = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.IsRawFile) + if (packageBundle.IsRawFile) { - _cachedBundleDepends.Add(patchBundle.BundleName, new string[] { }); + _cachedBundleDepends.Add(packageBundle.BundleName, new string[] { }); continue; } - if (buildResultContext.Results.BundleInfos.ContainsKey(patchBundle.BundleName) == false) - throw new Exception($"Not found bundle in SBP build results : {patchBundle.BundleName}"); + if (buildResultContext.Results.BundleInfos.ContainsKey(packageBundle.BundleName) == false) + throw new Exception($"Not found bundle in SBP build results : {packageBundle.BundleName}"); - var depends = buildResultContext.Results.BundleInfos[patchBundle.BundleName].Dependencies; - _cachedBundleDepends.Add(patchBundle.BundleName, depends); + var depends = buildResultContext.Results.BundleInfos[packageBundle.BundleName].Dependencies; + _cachedBundleDepends.Add(packageBundle.BundleName, depends); EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); // 计算资源包引用列表 - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle); + packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle); EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); } - private void UpdateBuiltinPipelineReference(PatchManifest patchManifest, TaskBuilding.BuildResultContext buildResultContext) + private void UpdateBuiltinPipelineReference(PackageManifest manifest, TaskBuilding.BuildResultContext buildResultContext) { int progressValue; - int totalCount = patchManifest.BundleList.Count; + int totalCount = manifest.BundleList.Count; // 缓存资源包ID _cachedBundleID.Clear(); progressValue = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - int bundleID = GetAssetBundleID(patchBundle.BundleName, patchManifest); - _cachedBundleID.Add(patchBundle.BundleName, bundleID); + int bundleID = GetAssetBundleID(packageBundle.BundleName, manifest); + _cachedBundleID.Add(packageBundle.BundleName, bundleID); EditorTools.DisplayProgressBar("缓存资源包索引", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); @@ -298,36 +298,36 @@ namespace YooAsset.Editor // 缓存资源包依赖 _cachedBundleDepends.Clear(); progressValue = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.IsRawFile) + if (packageBundle.IsRawFile) { - _cachedBundleDepends.Add(patchBundle.BundleName, new string[] { } ); + _cachedBundleDepends.Add(packageBundle.BundleName, new string[] { } ); continue; } - var depends = buildResultContext.UnityManifest.GetDirectDependencies(patchBundle.BundleName); - _cachedBundleDepends.Add(patchBundle.BundleName, depends); + var depends = buildResultContext.UnityManifest.GetDirectDependencies(packageBundle.BundleName); + _cachedBundleDepends.Add(packageBundle.BundleName, depends); EditorTools.DisplayProgressBar("缓存资源包依赖列表", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); // 计算资源包引用列表 progressValue = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - patchBundle.ReferenceIDs = GetBundleRefrenceIDs(patchManifest, patchBundle); + packageBundle.ReferenceIDs = GetBundleRefrenceIDs(manifest, packageBundle); EditorTools.DisplayProgressBar("计算资源包引用关系", ++progressValue, totalCount); } EditorTools.ClearProgressBar(); } - private int[] GetBundleRefrenceIDs(PatchManifest patchManifest, PatchBundle targetBundle) + private int[] GetBundleRefrenceIDs(PackageManifest manifest, PackageBundle targetBundle) { List referenceList = new List(); - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - string bundleName = patchBundle.BundleName; + string bundleName = packageBundle.BundleName; if (bundleName == targetBundle.BundleName) continue; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchManifest.cs.meta rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateManifest.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs similarity index 84% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs index 54a908e..4f891bb 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; namespace YooAsset.Editor { - [TaskAttribute("制作补丁包")] - public class TaskCreatePatchPackage : IBuildTask + [TaskAttribute("制作包裹")] + public class TaskCreatePackage : IBuildTask { void IBuildTask.Run(BuildContext context) { @@ -13,14 +13,14 @@ namespace YooAsset.Editor var buildMode = buildParameters.Parameters.BuildMode; if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) { - CopyPatchFiles(buildParameters, buildMapContext); + CopyPackageFiles(buildParameters, buildMapContext); } } /// /// 拷贝补丁文件到补丁包目录 /// - private void CopyPatchFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext) + private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext) { var buildParameters = buildParametersContext.Parameters; string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); @@ -67,11 +67,11 @@ namespace YooAsset.Editor // 拷贝所有补丁文件 int progressValue = 0; - int patchFileTotalCount = buildMapContext.Collection.Count; + int fileTotalCount = buildMapContext.Collection.Count; foreach (var bundleInfo in buildMapContext.Collection) { - EditorTools.CopyFile(bundleInfo.PatchInfo.BuildOutputFilePath, bundleInfo.PatchInfo.PatchOutputFilePath, true); - EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, patchFileTotalCount); + EditorTools.CopyFile(bundleInfo.BundleInfo.BuildOutputFilePath, bundleInfo.BundleInfo.PackageOutputFilePath, true); + EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount); } EditorTools.ClearProgressBar(); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs.meta rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePackage.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 4f4e5eb..7f3a0cf 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -12,21 +12,21 @@ namespace YooAsset.Editor { var buildParameters = context.GetContextObject(); var buildMapContext = context.GetContextObject(); - var patchManifestContext = context.GetContextObject(); + var manifestContext = context.GetContextObject(); var buildMode = buildParameters.Parameters.BuildMode; if (buildMode != EBuildMode.SimulateBuild) { - CreateReportFile(buildParameters, buildMapContext, patchManifestContext); + CreateReportFile(buildParameters, buildMapContext, manifestContext); } } - private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, PatchManifestContext patchManifestContext) + private void CreateReportFile(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext, ManifestContext manifestContext) { var buildParameters = buildParametersContext.Parameters; string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); - PatchManifest patchManifest = patchManifestContext.Manifest; + PackageManifest manifest = manifestContext.Manifest; BuildReport buildReport = new BuildReport(); // 概述信息 @@ -57,46 +57,46 @@ namespace YooAsset.Editor // 构建结果 buildReport.Summary.AssetFileTotalCount = buildMapContext.AssetFileCount; - buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(patchManifest); - buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(patchManifest); - buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(patchManifest); - buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(patchManifest); - buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(patchManifest); - buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(patchManifest); - buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(patchManifest); + buildReport.Summary.MainAssetTotalCount = GetMainAssetCount(manifest); + buildReport.Summary.AllBundleTotalCount = GetAllBundleCount(manifest); + buildReport.Summary.AllBundleTotalSize = GetAllBundleSize(manifest); + buildReport.Summary.EncryptedBundleTotalCount = GetEncryptedBundleCount(manifest); + buildReport.Summary.EncryptedBundleTotalSize = GetEncryptedBundleSize(manifest); + buildReport.Summary.RawBundleTotalCount = GetRawBundleCount(manifest); + buildReport.Summary.RawBundleTotalSize = GetRawBundleSize(manifest); } // 资源对象列表 - buildReport.AssetInfos = new List(patchManifest.AssetList.Count); - foreach (var patchAsset in patchManifest.AssetList) + buildReport.AssetInfos = new List(manifest.AssetList.Count); + foreach (var packageAsset in manifest.AssetList) { - var mainBundle = patchManifest.BundleList[patchAsset.BundleID]; + var mainBundle = manifest.BundleList[packageAsset.BundleID]; ReportAssetInfo reportAssetInfo = new ReportAssetInfo(); - reportAssetInfo.Address = patchAsset.Address; - reportAssetInfo.AssetPath = patchAsset.AssetPath; - reportAssetInfo.AssetTags = patchAsset.AssetTags; - reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(patchAsset.AssetPath); + reportAssetInfo.Address = packageAsset.Address; + reportAssetInfo.AssetPath = packageAsset.AssetPath; + reportAssetInfo.AssetTags = packageAsset.AssetTags; + reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath); reportAssetInfo.MainBundleName = mainBundle.BundleName; reportAssetInfo.MainBundleSize = mainBundle.FileSize; - reportAssetInfo.DependBundles = GetDependBundles(patchManifest, patchAsset); - reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, patchAsset.AssetPath); + reportAssetInfo.DependBundles = GetDependBundles(manifest, packageAsset); + reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath); buildReport.AssetInfos.Add(reportAssetInfo); } // 资源包列表 - buildReport.BundleInfos = new List(patchManifest.BundleList.Count); - foreach (var patchBundle in patchManifest.BundleList) + buildReport.BundleInfos = new List(manifest.BundleList.Count); + foreach (var packageBundle in manifest.BundleList) { ReportBundleInfo reportBundleInfo = new ReportBundleInfo(); - reportBundleInfo.BundleName = patchBundle.BundleName; - reportBundleInfo.FileName = patchBundle.FileName; - reportBundleInfo.FileHash = patchBundle.FileHash; - reportBundleInfo.FileCRC = patchBundle.FileCRC; - reportBundleInfo.FileSize = patchBundle.FileSize; - reportBundleInfo.Tags = patchBundle.Tags; - reportBundleInfo.ReferenceIDs = patchBundle.ReferenceIDs; - reportBundleInfo.IsRawFile = patchBundle.IsRawFile; - reportBundleInfo.LoadMethod = (EBundleLoadMethod)patchBundle.LoadMethod; + reportBundleInfo.BundleName = packageBundle.BundleName; + reportBundleInfo.FileName = packageBundle.FileName; + reportBundleInfo.FileHash = packageBundle.FileHash; + reportBundleInfo.FileCRC = packageBundle.FileCRC; + reportBundleInfo.FileSize = packageBundle.FileSize; + reportBundleInfo.Tags = packageBundle.Tags; + reportBundleInfo.ReferenceIDs = packageBundle.ReferenceIDs; + reportBundleInfo.IsRawFile = packageBundle.IsRawFile; + reportBundleInfo.LoadMethod = (EBundleLoadMethod)packageBundle.LoadMethod; buildReport.BundleInfos.Add(reportBundleInfo); } @@ -110,12 +110,12 @@ namespace YooAsset.Editor /// /// 获取资源对象依赖的所有资源包 /// - private List GetDependBundles(PatchManifest patchManifest, PatchAsset patchAsset) + private List GetDependBundles(PackageManifest manifest, PackageAsset packageAsset) { - List dependBundles = new List(patchAsset.DependIDs.Length); - foreach (int index in patchAsset.DependIDs) + List dependBundles = new List(packageAsset.DependIDs.Length); + foreach (int index in packageAsset.DependIDs) { - string dependBundleName = patchManifest.BundleList[index].BundleName; + string dependBundleName = manifest.BundleList[index].BundleName; dependBundles.Add(dependBundleName); } return dependBundles; @@ -150,60 +150,60 @@ namespace YooAsset.Editor return result; } - private int GetMainAssetCount(PatchManifest patchManifest) + private int GetMainAssetCount(PackageManifest manifest) { - return patchManifest.AssetList.Count; + return manifest.AssetList.Count; } - private int GetAllBundleCount(PatchManifest patchManifest) + private int GetAllBundleCount(PackageManifest manifest) { - return patchManifest.BundleList.Count; + return manifest.BundleList.Count; } - private long GetAllBundleSize(PatchManifest patchManifest) + private long GetAllBundleSize(PackageManifest manifest) { long fileBytes = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - fileBytes += patchBundle.FileSize; + fileBytes += packageBundle.FileSize; } return fileBytes; } - private int GetEncryptedBundleCount(PatchManifest patchManifest) + private int GetEncryptedBundleCount(PackageManifest manifest) { int fileCount = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) + if (packageBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) fileCount++; } return fileCount; } - private long GetEncryptedBundleSize(PatchManifest patchManifest) + private long GetEncryptedBundleSize(PackageManifest manifest) { long fileBytes = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) - fileBytes += patchBundle.FileSize; + if (packageBundle.LoadMethod != (byte)EBundleLoadMethod.Normal) + fileBytes += packageBundle.FileSize; } return fileBytes; } - private int GetRawBundleCount(PatchManifest patchManifest) + private int GetRawBundleCount(PackageManifest manifest) { int fileCount = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.IsRawFile) + if (packageBundle.IsRawFile) fileCount++; } return fileCount; } - private long GetRawBundleSize(PatchManifest patchManifest) + private long GetRawBundleSize(PackageManifest manifest) { long fileBytes = 0; - foreach (var patchBundle in patchManifest.BundleList) + foreach (var packageBundle in manifest.BundleList) { - if (patchBundle.IsRawFile) - fileBytes += patchBundle.FileSize; + if (packageBundle.IsRawFile) + fileBytes += packageBundle.FileSize; } return fileBytes; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs similarity index 76% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs index 06f8a3d..f907a8e 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs @@ -6,8 +6,8 @@ using UnityEditor; namespace YooAsset.Editor { - [TaskAttribute("更新补丁信息")] - public class TaskUpdatePatchInfo : IBuildTask + [TaskAttribute("更新资源包信息")] + public class TaskUpdateBundleInfo : IBuildTask { void IBuildTask.Run(BuildContext context) { @@ -30,27 +30,27 @@ namespace YooAsset.Editor foreach (var bundleInfo in buildMapContext.Collection) { if (bundleInfo.IsEncryptedFile) - bundleInfo.PatchInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath; + bundleInfo.BundleInfo.BuildOutputFilePath = bundleInfo.EncryptedFilePath; else - bundleInfo.PatchInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; + bundleInfo.BundleInfo.BuildOutputFilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; } // 3.更新文件其它信息 foreach (var bundleInfo in buildMapContext.Collection) { - string buildOutputFilePath = bundleInfo.PatchInfo.BuildOutputFilePath; - bundleInfo.PatchInfo.ContentHash = GetBundleContentHash(bundleInfo, context); - bundleInfo.PatchInfo.PatchFileHash = GetBundleFileHash(buildOutputFilePath, buildParametersContext); - bundleInfo.PatchInfo.PatchFileCRC = GetBundleFileCRC(buildOutputFilePath, buildParametersContext); - bundleInfo.PatchInfo.PatchFileSize = GetBundleFileSize(buildOutputFilePath, buildParametersContext); + string buildOutputFilePath = bundleInfo.BundleInfo.BuildOutputFilePath; + bundleInfo.BundleInfo.ContentHash = GetBundleContentHash(bundleInfo, context); + bundleInfo.BundleInfo.FileHash = GetBundleFileHash(buildOutputFilePath, buildParametersContext); + bundleInfo.BundleInfo.FileCRC = GetBundleFileCRC(buildOutputFilePath, buildParametersContext); + bundleInfo.BundleInfo.FileSize = GetBundleFileSize(buildOutputFilePath, buildParametersContext); } // 4.更新补丁包输出的文件路径 foreach (var bundleInfo in buildMapContext.Collection) { - string patchFileExtension = PatchManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName); - string patchFileName = PatchManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, patchFileExtension, bundleInfo.PatchInfo.PatchFileHash); - bundleInfo.PatchInfo.PatchOutputFilePath = $"{packageOutputDirectory}/{patchFileName}"; + string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleInfo.BundleName); + string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleInfo.BundleName, fileExtension, bundleInfo.BundleInfo.FileHash); + bundleInfo.BundleInfo.PackageOutputFilePath = $"{packageOutputDirectory}/{fileName}"; } } @@ -64,7 +64,7 @@ namespace YooAsset.Editor if (bundleInfo.IsRawFile) { - string filePath = bundleInfo.PatchInfo.BuildOutputFilePath; + string filePath = bundleInfo.BundleInfo.BuildOutputFilePath; return HashUtility.FileMD5(filePath); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs.meta b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs.meta similarity index 100% rename from Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdatePatchInfo.cs.meta rename to Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskUpdateBundleInfo.cs.meta