diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs index 4c0bd888..c9b087d9 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildBundleInfo.cs @@ -56,13 +56,13 @@ namespace YooAsset.Editor public string EncryptedFilePath { set; get; } #endregion - private readonly HashSet _assetPaths = new HashSet(); + private readonly Dictionary _packAssetDic = new Dictionary(100); /// /// 参与构建的资源列表 /// 注意:不包含零依赖资源和冗余资源 /// - public readonly List MainAssets = new List(); + public readonly List AllPackAssets = new List(100); /// /// 资源包名称 @@ -86,51 +86,68 @@ namespace YooAsset.Editor public void PackAsset(BuildAssetInfo buildAsset) { string assetPath = buildAsset.AssetInfo.AssetPath; - if (_assetPaths.Contains(assetPath)) + if (_packAssetDic.ContainsKey(assetPath)) throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}"); - _assetPaths.Add(assetPath); - MainAssets.Add(buildAsset); + _packAssetDic.Add(assetPath, buildAsset); + AllPackAssets.Add(buildAsset); } /// /// 是否包含指定资源 /// - public bool IsContainsAsset(string assetPath) + public bool IsContainsPackAsset(string assetPath) { - return _assetPaths.Contains(assetPath); + return _packAssetDic.ContainsKey(assetPath); } /// /// 获取构建的资源路径列表 /// - public string[] GetAllMainAssetPaths() + public string[] GetAllPackAssetPaths() { - return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray(); + return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray(); } /// - /// 获取该资源包内的所有资源(包括零依赖资源和冗余资源) + /// 获取构建的主资源信息 /// - public List GetAllBuiltinAssetPaths() + public BuildAssetInfo GetPackAssetInfo(string assetPath) { - var packAssets = GetAllMainAssetPaths(); - List result = new List(packAssets); - foreach (var buildAsset in MainAssets) + if (_packAssetDic.TryGetValue(assetPath, out BuildAssetInfo value)) { - if (buildAsset.AllDependAssetInfos == null) - continue; - foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos) + return value; + } + else + { + throw new Exception($"Can not found pack asset info {assetPath} in bundle : {BundleName}"); + } + } + + /// + /// 获取资源包内部所有资产 + /// + public List GetBundleContents() + { + Dictionary result = new Dictionary(AllPackAssets.Count); + foreach (var packAsset in AllPackAssets) + { + result.Add(packAsset.AssetInfo.AssetPath, packAsset.AssetInfo); + if (packAsset.AllDependAssetInfos != null) { - // 注意:依赖资源里只添加零依赖资源和冗余资源 - if (dependAssetInfo.HasBundleName() == false) + foreach (var dependAssetInfo in packAsset.AllDependAssetInfos) { - if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false) - result.Add(dependAssetInfo.AssetInfo.AssetPath); + // 注意:依赖资源里只添加零依赖资源和冗余资源 + if (dependAssetInfo.HasBundleName() == false) + { + string dependAssetPath = dependAssetInfo.AssetInfo.AssetPath; + if (result.ContainsKey(dependAssetPath) == false) + result.Add(dependAssetPath, dependAssetInfo.AssetInfo); + } } } } - return result; + return result.Values.ToList(); } /// @@ -142,7 +159,7 @@ namespace YooAsset.Editor AssetBundleBuild build = new AssetBundleBuild(); build.assetBundleName = BundleName; build.assetBundleVariant = string.Empty; - build.assetNames = GetAllMainAssetPaths(); + build.assetNames = GetAllPackAssetPaths(); return build; } @@ -151,7 +168,7 @@ namespace YooAsset.Editor /// public BuildAssetInfo[] GetAllManifestAssetInfos() { - return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); + return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray(); } /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs index 4b091dd0..05dbf905 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildParameters.cs @@ -53,7 +53,7 @@ namespace YooAsset.Editor /// /// 怀旧版依赖模式 - /// 说明:兼容YooAssets1.5.x版本 + /// 说明:兼容YooAsset1.5.x版本 /// public bool LegacyDependency = false; diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs index 5f51d29d..cba632be 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs @@ -34,37 +34,35 @@ namespace YooAsset.Editor buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable; buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower; buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID; - buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName; buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders; + buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName; // 构建参数 buildReport.Summary.LegacyDependency = buildParameters.LegacyDependency; buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles; buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB; buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule; + buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone; + buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName; - if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline)) + if (buildParameters is BuiltinBuildParameters) { var builtinBuildParameters = buildParameters as BuiltinBuildParameters; - buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption; buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree; buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges; } - else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline)) + else if (buildParameters is ScriptableBuildParameters) { var scriptableBuildParameters = buildParameters as ScriptableBuildParameters; - buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption; buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree; buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges; - } - else - { - buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; - buildReport.Summary.CompressOption = ECompressOption.Uncompressed; - buildReport.Summary.DisableWriteTypeTree = false; - buildReport.Summary.IgnoreTypeTreeChanges = false; + buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML; + buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost; + buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort; + buildReport.Summary.BuiltinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName; + buildReport.Summary.MonoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName; } // 构建结果 @@ -88,7 +86,8 @@ namespace YooAsset.Editor reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath); reportAssetInfo.MainBundleName = mainBundle.BundleName; reportAssetInfo.MainBundleSize = mainBundle.FileSize; - reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath); + reportAssetInfo.DependAssets = GetAssetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath); + reportAssetInfo.DependBundles = GetAssetDependBundles(manifest, packageAsset); buildReport.AssetInfos.Add(reportAssetInfo); } @@ -104,8 +103,9 @@ namespace YooAsset.Editor reportBundleInfo.FileSize = packageBundle.FileSize; reportBundleInfo.Encrypted = packageBundle.Encrypted; reportBundleInfo.Tags = packageBundle.Tags; - reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle); - reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName); + reportBundleInfo.DependBundles = GetBundleDependBundles(manifest, packageBundle); + reportBundleInfo.ReferenceBundles = GetBundleReferenceBundles(manifest, packageBundle); + reportBundleInfo.BundleContents = GetBundleContents(buildMapContext, packageBundle.BundleName); buildReport.BundleInfos.Add(reportBundleInfo); } @@ -120,9 +120,40 @@ namespace YooAsset.Editor } /// - /// 获取资源对象依赖的所有资源包 + /// 获取资源对象依赖的其它所有资源 /// - private List GetDependBundles(PackageManifest manifest, PackageBundle packageBundle) + private List GetAssetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath) + { + List result = new List(); + var bundleInfo = buildMapContext.GetBundleInfo(bundleName); + var assetInfo = bundleInfo.GetPackAssetInfo(assetPath); + foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) + { + result.Add(dependAssetInfo.AssetInfo); + } + result.Sort(); + return result; + } + + /// + /// 获取资源对象依赖的资源包集合 + /// + private List GetAssetDependBundles(PackageManifest manifest, PackageAsset packageAsset) + { + List dependBundles = new List(packageAsset.DependBundleIDs.Length); + foreach (int index in packageAsset.DependBundleIDs) + { + string dependBundleName = manifest.BundleList[index].BundleName; + dependBundles.Add(dependBundleName); + } + dependBundles.Sort(); + return dependBundles; + } + + /// + /// 获取资源包依赖的资源包集合 + /// + private List GetBundleDependBundles(PackageManifest manifest, PackageBundle packageBundle) { List dependBundles = new List(packageBundle.DependIDs.Length); foreach (int index in packageBundle.DependIDs) @@ -135,42 +166,27 @@ namespace YooAsset.Editor } /// - /// 获取资源对象依赖的其它所有资源 + /// 获取引用该资源包的资源包集合 /// - private List GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath) + private List GetBundleReferenceBundles(PackageManifest manifest, PackageBundle packageBundle) { - List result = new List(); - var bundleInfo = buildMapContext.GetBundleInfo(bundleName); + List referenceBundles = new List(packageBundle.ReferenceBundleIDs.Length); + foreach (int index in packageBundle.ReferenceBundleIDs) { - BuildAssetInfo findAssetInfo = null; - foreach (var buildAsset in bundleInfo.MainAssets) - { - if (buildAsset.AssetInfo.AssetPath == assetPath) - { - findAssetInfo = buildAsset; - break; - } - } - if (findAssetInfo == null) - { - throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}"); - } - foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos) - { - result.Add(dependAssetInfo.AssetInfo.AssetPath); - } + string dependBundleName = manifest.BundleList[index].BundleName; + referenceBundles.Add(dependBundleName); } - result.Sort(); - return result; + referenceBundles.Sort(); + return referenceBundles; } /// - /// 获取该资源包内的所有资源 + /// 获取资源包内部所有资产 /// - private List GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName) + private List GetBundleContents(BuildMapContext buildMapContext, string bundleName) { var bundleInfo = buildMapContext.GetBundleInfo(bundleName); - List result = bundleInfo.GetAllBuiltinAssetPaths(); + List result = bundleInfo.GetBundleContents(); result.Sort(); return result; } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/EditorSimulateBuildPipeline/BuildTasks/TaskUpdateBundleInfo_ESBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/EditorSimulateBuildPipeline/BuildTasks/TaskUpdateBundleInfo_ESBP.cs index 88d98a76..5d2745fa 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/EditorSimulateBuildPipeline/BuildTasks/TaskUpdateBundleInfo_ESBP.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/EditorSimulateBuildPipeline/BuildTasks/TaskUpdateBundleInfo_ESBP.cs @@ -45,7 +45,7 @@ namespace YooAsset.Editor { long tempSize = 0; - var assetPaths = bundleInfo.GetAllMainAssetPaths(); + var assetPaths = bundleInfo.GetAllPackAssetPaths(); foreach (var assetPath in assetPaths) { long size = FileUtility.GetFileSize(assetPath); diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs index b307a233..7a85664b 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskBuilding_RFBP.cs @@ -23,7 +23,7 @@ namespace YooAsset.Editor foreach (var bundleInfo in buildMapContext.Collection) { string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; - foreach (var buildAsset in bundleInfo.MainAssets) + foreach (var buildAsset in bundleInfo.AllPackAssets) { EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true); } diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskGetBuildMap_RFBP.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskGetBuildMap_RFBP.cs index 720b9336..2d3f1dd0 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskGetBuildMap_RFBP.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/RawFileBuildPipeline/BuildTasks/TaskGetBuildMap_RFBP.cs @@ -27,7 +27,7 @@ namespace YooAsset.Editor // 注意:原生文件资源包只能包含一个原生文件 foreach (var bundleInfo in buildMapContext.Collection) { - if (bundleInfo.MainAssets.Count != 1) + if (bundleInfo.AllPackAssets.Count != 1) { string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}"); throw new Exception(message); diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportAssetInfo.cs index 19fdeb31..ab1e0d7e 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportAssetInfo.cs @@ -39,8 +39,14 @@ namespace YooAsset.Editor public long MainBundleSize; /// - /// 依赖的资源路径列表 + /// 依赖的资源集合 /// - public List DependAssets = new List(); + public List DependAssets = new List(); + + /// + /// 依赖的资源包集合 + /// 说明:框架层收集查询结果 + /// + public List DependBundles = new List(); } } \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportBundleInfo.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportBundleInfo.cs index 299b3d10..6ab6cdef 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportBundleInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportBundleInfo.cs @@ -44,14 +44,21 @@ namespace YooAsset.Editor public string[] Tags; /// - /// 资源包的依赖集合 + /// 依赖的资源包集合 + /// 说明:引擎层构建查询结果 /// - public List DependBundles; + public List DependBundles = new List(); /// - /// 该资源包内包含的所有资源 + /// 引用该资源包的资源包集合 + /// 说明:谁依赖该资源包 /// - public List AllBuiltinAssets = new List(); + public List ReferenceBundles = new List(); + + /// + /// 资源包内部所有资产 + /// + public List BundleContents = new List(); /// /// 获取资源分类标签的字符串 diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportSummary.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportSummary.cs index bf13b6fd..6d86debc 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportSummary.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/ReportSummary.cs @@ -71,11 +71,19 @@ namespace YooAsset.Editor public bool ClearBuildCacheFiles; public bool UseAssetDependencyDB; public bool EnableSharePackRule; + public bool SingleReferencedPackAlone; public string EncryptionClassName; public EFileNameStyle FileNameStyle; + + // 引擎参数 public ECompressOption CompressOption; public bool DisableWriteTypeTree; public bool IgnoreTypeTreeChanges; + public bool WriteLinkXML = true; + public string CacheServerHost; + public int CacheServerPort; + public string BuiltinShadersBundleName; + public string MonoScriptsBundleName; // 构建结果 public int AssetFileTotalCount; diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs index 1fb6ddb0..c6e8fff6 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterAssetListViewer.cs @@ -116,6 +116,7 @@ namespace YooAsset.Editor columnStyle.Stretchable = true; columnStyle.Searchable = true; columnStyle.Sortable = true; + columnStyle.Counter = true; var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle); column.MakeCell = () => { diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs index b6309a60..29b12842 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterBundleListViewer.cs @@ -320,15 +320,15 @@ namespace YooAsset.Editor sourceDatas.Add(rowData); } } - foreach (string assetPath in bundleInfo.AllBuiltinAssets) + foreach (var assetInfo in bundleInfo.BundleContents) { - if (mainAssetDic.Contains(assetPath) == false) + if (mainAssetDic.Contains(assetInfo.AssetPath) == false) { var rowData = new IncludeTableData(); rowData.AssetInfo = null; - rowData.AddAssetPathCell("IncludeAssets", assetPath); + rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath); rowData.AddStringValueCell("AssetSource", "BuiltinAsset"); - rowData.AddStringValueCell("AssetGUID", "--"); + rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID); sourceDatas.Add(rowData); } } diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs index 9c9ae7c0..bcafd59e 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterSummaryViewer.cs @@ -11,24 +11,9 @@ namespace YooAsset.Editor { internal class ReporterSummaryViewer { - private class ItemWrapper - { - public string Title { private set; get; } - public string Value { private set; get; } - - public ItemWrapper(string title, string value) - { - Title = title; - Value = value; - } - } - private VisualTreeAsset _visualAsset; private TemplateContainer _root; - - private ListView _listView; - private readonly List _items = new List(); - + private ScrollView _scrollView; /// /// 初始化页面 @@ -44,9 +29,7 @@ namespace YooAsset.Editor _root.style.flexGrow = 1f; // 概述列表 - _listView = _root.Q("ListView"); - _listView.makeItem = MakeListViewItem; - _listView.bindItem = BindListViewItem; + _scrollView = _root.Q("ScrollView"); } /// @@ -54,53 +37,50 @@ namespace YooAsset.Editor /// public void FillViewData(BuildReport buildReport) { - _items.Clear(); + _scrollView.Clear(); - _items.Add(new ItemWrapper("YooAsset Version", buildReport.Summary.YooVersion)); - _items.Add(new ItemWrapper("UnityEngine Version", buildReport.Summary.UnityVersion)); - _items.Add(new ItemWrapper("Build Date", buildReport.Summary.BuildDate)); - _items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds))); - _items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}")); - _items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}")); - _items.Add(new ItemWrapper("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString())); - _items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName)); - _items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion)); - _items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote)); + BindListViewHeader("Build Infos"); + BindListViewItem("YooAsset Version", buildReport.Summary.YooVersion); + BindListViewItem("UnityEngine Version", buildReport.Summary.UnityVersion); + BindListViewItem("Build Date", buildReport.Summary.BuildDate); + BindListViewItem("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)); + BindListViewItem("Build Target", $"{buildReport.Summary.BuildTarget}"); + BindListViewItem("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"); + BindListViewItem("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString()); + BindListViewItem("Package Name", buildReport.Summary.BuildPackageName); + BindListViewItem("Package Version", buildReport.Summary.BuildPackageVersion); + BindListViewItem("Package Note", buildReport.Summary.BuildPackageNote); + BindListViewItem(string.Empty, string.Empty); - _items.Add(new ItemWrapper(string.Empty, string.Empty)); - _items.Add(new ItemWrapper("Collect Settings", string.Empty)); - _items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}")); - _items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}")); - _items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}")); - _items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}")); - _items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}")); - _items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}")); - - _items.Add(new ItemWrapper(string.Empty, string.Empty)); - _items.Add(new ItemWrapper("Build Params", string.Empty)); - _items.Add(new ItemWrapper("Legacy Dependency Mode", $"{buildReport.Summary.LegacyDependency}")); - _items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}")); - _items.Add(new ItemWrapper("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}")); - _items.Add(new ItemWrapper("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}")); - _items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName)); - _items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}")); - _items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}")); - _items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}")); - _items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}")); + BindListViewHeader("Collect Settings"); + BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"); + BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"); + BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}"); + BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"); + BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"); + BindListViewItem("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"); + BindListViewItem(string.Empty, string.Empty); - _items.Add(new ItemWrapper(string.Empty, string.Empty)); - _items.Add(new ItemWrapper("Build Results", string.Empty)); - _items.Add(new ItemWrapper("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}")); - _items.Add(new ItemWrapper("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}")); - _items.Add(new ItemWrapper("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}")); - _items.Add(new ItemWrapper("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize))); - _items.Add(new ItemWrapper("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}")); - _items.Add(new ItemWrapper("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize))); + BindListViewHeader("Build Params"); + BindListViewItem("Legacy Dependency Mode", $"{buildReport.Summary.LegacyDependency}"); + BindListViewItem("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}"); + BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}"); + BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"); + BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}"); + BindListViewItem("Encryption Class Name", buildReport.Summary.EncryptionClassName); + BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"); + BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}"); + BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"); + BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"); + BindListViewItem(string.Empty, string.Empty); - _listView.Clear(); - _listView.ClearSelection(); - _listView.itemsSource = _items; - _listView.Rebuild(); + BindListViewHeader("Build Results"); + BindListViewItem("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}"); + BindListViewItem("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}"); + BindListViewItem("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}"); + BindListViewItem("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize)); + BindListViewItem("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}"); + BindListViewItem("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)); } /// @@ -120,45 +100,60 @@ namespace YooAsset.Editor } // 列表相关 + private void BindListViewHeader(string titile) + { + Toolbar toolbar = new Toolbar(); + _scrollView.Add(toolbar); + + ToolbarButton titleButton = new ToolbarButton(); + titleButton.text = titile; + titleButton.style.unityTextAlign = TextAnchor.MiddleCenter; + titleButton.style.width = 200; + toolbar.Add(titleButton); + + ToolbarButton valueButton = new ToolbarButton(); + valueButton.style.unityTextAlign = TextAnchor.MiddleCenter; + valueButton.style.width = 150; + valueButton.style.flexShrink = 1; + valueButton.style.flexGrow = 1; + valueButton.SetEnabled(false); + toolbar.Add(valueButton); + } + private void BindListViewItem(string name, string value) + { + VisualElement element = MakeListViewItem(); + _scrollView.Add(element); + + // Title + var titleLabel = element.Q public bool Sortable = false; + /// + /// 统计数量 + /// + public bool Counter = false; + public ColumnStyle(Length width) { if (width.value > MaxValue) diff --git a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs index 37bf1ccf..af49da91 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs @@ -89,7 +89,7 @@ namespace YooAsset.Editor // 定义标题栏 _toolbar = new Toolbar(); - + // 定义列表视图 _listView = new ListView(); _listView.style.flexShrink = 1f; @@ -191,6 +191,16 @@ namespace YooAsset.Editor _listView.ClearSelection(); _listView.itemsSource = itemsSource.ToList(); _listView.Rebuild(); + + // 动态设置元素数量 + foreach (var column in _columns) + { + if (column.ColumnStyle.Counter) + { + var toobarButton = GetHeaderElement(column.ElementName) as ToolbarButton; + toobarButton.text = $"{column.HeaderTitle} ({itemsSource.Count()})"; + } + } } ///