From 2838289650aba5944a65cd1d96065371910390c3 Mon Sep 17 00:00:00 2001 From: hevinci Date: Tue, 26 Dec 2023 11:30:19 +0800 Subject: [PATCH] feat : the build report file add independ asset info --- .../AssetBundleBuilder/BuildMapContext.cs | 2 +- .../BaseTasks/TaskCreateReport.cs | 3 +- .../BaseTasks/TaskGetBuildMap.cs | 21 +++++++++---- .../Editor/AssetBundleReporter/BuildReport.cs | 2 +- .../ReportIndependAsset.cs | 30 +++++++++++++++++++ .../ReportIndependAsset.cs.meta | 11 +++++++ .../ReportRedundancyAsset.cs | 14 +++++++-- .../ReporterRedundancyListViewer.cs | 16 +++++----- .../ReporterRedundancyListViewer.uxml | 2 +- 9 files changed, 81 insertions(+), 20 deletions(-) create mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs create mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs index d6b6ec9..ede340b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs @@ -21,7 +21,7 @@ namespace YooAsset.Editor /// /// 未被依赖的资源列表 /// - public readonly List UndependAssets = new List(1000); + public readonly List IndependAssets = new List(1000); /// /// 参与构建的资源总数 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs index 16d700c..15ec061 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs @@ -107,8 +107,9 @@ namespace YooAsset.Editor buildReport.BundleInfos.Add(reportBundleInfo); } - // 冗余资源列表 + // 资源列表 buildReport.RedundancyAssets = new List(buildMapContext.RedundancyInfos); + buildReport.IndependAssets = new List(buildMapContext.IndependAssets); // 序列化文件 string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs index 4c4f2f8..fbe1202 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs @@ -107,11 +107,13 @@ namespace YooAsset.Editor { if (buildAssetInfo.IsRedundancyAsset()) { - var redundancyInfo = new ReportRedundancyAsset(); - redundancyInfo.AssetInfo = buildAssetInfo.AssetInfo; - redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath); - redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount(); - context.RedundancyInfos.Add(redundancyInfo); + var redundancyAsset = new ReportRedundancyAsset(); + redundancyAsset.AssetPath = buildAssetInfo.AssetInfo.AssetPath; + redundancyAsset.AssetGUID = buildAssetInfo.AssetInfo.AssetGUID; + redundancyAsset.AssetType = buildAssetInfo.AssetInfo.AssetType.ToString(); + redundancyAsset.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetInfo.AssetPath); + redundancyAsset.Number = buildAssetInfo.GetReferenceBundleCount(); + context.RedundancyInfos.Add(redundancyAsset); } } @@ -179,7 +181,14 @@ namespace YooAsset.Editor { string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}"); BuildLogger.Warning(warning); - context.UndependAssets.Add(removeValue.AssetInfo); + + var independAsset = new ReportIndependAsset(); + independAsset.AssetPath = removeValue.AssetInfo.AssetPath; + independAsset.AssetGUID = removeValue.AssetInfo.AssetGUID; + independAsset.AssetType = removeValue.AssetInfo.AssetType.ToString(); + independAsset.FileSize = FileUtility.GetFileSize(removeValue.AssetInfo.AssetPath); + context.IndependAssets.Add(independAsset); + allCollectAssets.Remove(removeValue); } } diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs index 7ff89b8..9e101f3 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs @@ -35,7 +35,7 @@ namespace YooAsset.Editor /// /// 未被依赖的资源列表 /// - public List UndependAssets = new List(); + public List IndependAssets = new List(); /// /// 获取资源包信息类 diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs new file mode 100644 index 0000000..eb30add --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections; +using System.Collections.Generic; + +namespace YooAsset.Editor +{ + [Serializable] + public class ReportIndependAsset + { + /// + /// 资源路径 + /// + public string AssetPath; + + /// + /// 资源GUID + /// + public string AssetGUID; + + /// + /// 资源类型 + /// + public string AssetType; + + /// + /// 资源文件大小 + /// + public long FileSize; + } +} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs.meta b/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs.meta new file mode 100644 index 0000000..a2fb82b --- /dev/null +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportIndependAsset.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6f187b12ce298c0429119fcf194f2621 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs index 7cf6b14..9ffd045 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs @@ -8,9 +8,19 @@ namespace YooAsset.Editor public class ReportRedundancyAsset { /// - /// 资源信息 + /// 资源路径 /// - public AssetInfo AssetInfo; + public string AssetPath; + + /// + /// 资源GUID + /// + public string AssetGUID; + + /// + /// 资源类型 + /// + public string AssetType; /// /// 资源文件大小 diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs index 19d2490..f3cde91 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs @@ -89,7 +89,7 @@ namespace YooAsset.Editor { if (string.IsNullOrEmpty(_searchKeyWord) == false) { - if (redundancyInfo.AssetInfo.AssetPath.Contains(_searchKeyWord) == false) + if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false) continue; } result.Add(redundancyInfo); @@ -99,16 +99,16 @@ namespace YooAsset.Editor if (_sortMode == ESortMode.AssetPath) { if (_descendingSort) - return result.OrderByDescending(a => a.AssetInfo.AssetPath).ToList(); + return result.OrderByDescending(a => a.AssetPath).ToList(); else - return result.OrderBy(a => a.AssetInfo.AssetPath).ToList(); + return result.OrderBy(a => a.AssetPath).ToList(); } else if (_sortMode == ESortMode.AssetType) { if (_descendingSort) - return result.OrderByDescending(a => a.AssetInfo.AssetType).ToList(); + return result.OrderByDescending(a => a.AssetType).ToList(); else - return result.OrderBy(a => a.AssetInfo.AssetType).ToList(); + return result.OrderBy(a => a.AssetType).ToList(); } else if (_sortMode == ESortMode.FileSize) { @@ -209,7 +209,7 @@ namespace YooAsset.Editor label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.marginLeft = 3f; label.style.flexGrow = 0; - label.style.width = 125; + label.style.width = 200; element.Add(label); } @@ -242,11 +242,11 @@ namespace YooAsset.Editor // Asset Path var label1 = element.Q