From 512093b0ba9cf495a7ff2f15a48922e782d4dad3 Mon Sep 17 00:00:00 2001 From: hevinci Date: Fri, 18 Mar 2022 11:25:07 +0800 Subject: [PATCH] Update AssetBundleBuilder --- .../BuildReport/BuildReport.cs | 35 ++++++++++++++++--- .../BuildReport/ReportAssetInfo.cs | 6 ++-- .../BuildTasks/TaskCreatePatchPackage.cs | 8 +++++ .../BuildTasks/TaskCreateReadme.cs | 4 +-- .../BuildTasks/TaskCreateReport.cs | 3 ++ .../BuildTasks/TaskGetBuildMap.cs | 6 ++-- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs index bc33833..0ae1492 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/BuildReport.cs @@ -26,19 +26,44 @@ namespace YooAsset.Editor /// public List BundleInfos = new List(); + /// + /// 冗余的资源列表 + /// + public List RedundancyAssetList = new List(); + /// - /// 序列化 + /// 获取资源包信息类 /// + public ReportBundleInfo GetBundleInfo(string bundleName) + { + foreach (var bundleInfo in BundleInfos) + { + if (bundleInfo.BundleName == bundleName) + return bundleInfo; + } + throw new Exception($"Not found bundle : {bundleName}"); + } + + /// + /// 获取资源信息类 + /// + public ReportAssetInfo GetAssetInfo(string assetPath) + { + foreach (var assetInfo in AssetInfos) + { + if (assetInfo.AssetPath == assetPath) + return assetInfo; + } + throw new Exception($"Not found asset : {assetPath}"); + } + + public static void Serialize(string savePath, BuildReport buildReport) { string json = JsonUtility.ToJson(buildReport, true); FileUtility.CreateFile(savePath, json); } - - /// - /// 反序列化 - /// public static BuildReport Deserialize(string jsonData) { BuildReport report = JsonUtility.FromJson(jsonData); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs index 9f5646f..1c03bc6 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildReport/ReportAssetInfo.cs @@ -13,17 +13,17 @@ namespace YooAsset.Editor public string AssetPath; /// - /// 所属资源包 + /// 所属资源包名称 /// public string MainBundle; /// - /// 依赖的资源包 + /// 依赖的资源包名称列表 /// public List DependBundles = new List(); /// - /// 依赖的资源列表 + /// 依赖的资源路径列表 /// public List DependAssets = new List(); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs index a4b8b6f..7b59887 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreatePatchPackage.cs @@ -30,6 +30,14 @@ namespace YooAsset.Editor UnityEngine.Debug.Log($"拷贝Readme文件到:{destPath}"); } + // 拷贝Report文件 + { + string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}"; + string destPath = $"{packageDirectory}/{ResourceSettingData.Setting.ReportFileName}"; + EditorTools.CopyFile(sourcePath, destPath, true); + UnityEngine.Debug.Log($"拷贝Report文件到:{destPath}"); + } + // 拷贝PatchManifest文件 { string sourcePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.PatchManifestFileName}"; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs index 14e4108..996d5a7 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReadme.cs @@ -77,9 +77,9 @@ namespace YooAsset.Editor AppendData(content, ""); AppendData(content, $"--冗余列表--"); - for (int i = 0; i < buildMapContext.RedundancyList.Count; i++) + for (int i = 0; i < buildMapContext.RedundancyAssetList.Count; i++) { - string redundancyAssetPath = buildMapContext.RedundancyList[i]; + string redundancyAssetPath = buildMapContext.RedundancyAssetList[i]; AppendData(content, redundancyAssetPath); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs index 21c6b8d..c903564 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskCreateReport.cs @@ -67,6 +67,9 @@ namespace YooAsset.Editor buildReport.BundleInfos.Add(reportBundleInfo); } + // 冗余资源列表 + buildReport.RedundancyAssetList = buildMapContext.RedundancyAssetList; + // 删除旧文件 string filePath = $"{buildParameters.PipelineOutputDirectory}/{ResourceSettingData.Setting.ReportFileName}"; if (File.Exists(filePath)) diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs index 2b5381d..bce262c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildTasks/TaskGetBuildMap.cs @@ -19,7 +19,7 @@ namespace YooAsset.Editor /// /// 冗余的资源列表 /// - public readonly List RedundancyList = new List(1000); + public readonly List RedundancyAssetList = new List(1000); /// @@ -201,7 +201,7 @@ namespace YooAsset.Editor if(redundancy.Check(buildAssetInfo.AssetPath)) { undependentAssets.Add(buildAssetInfo); - buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath); + buildMapContext.RedundancyAssetList.Add(buildAssetInfo.AssetPath); continue; } } @@ -212,7 +212,7 @@ namespace YooAsset.Editor if (AssetBundleCollectorSettingData.HasCollector(buildAssetInfo.AssetPath) == false) { undependentAssets.Add(buildAssetInfo); - buildMapContext.RedundancyList.Add(buildAssetInfo.AssetPath); + buildMapContext.RedundancyAssetList.Add(buildAssetInfo.AssetPath); } } }