From cbdb84a69f7b0729ecba8e400dbed167c490c650 Mon Sep 17 00:00:00 2001 From: hevinci Date: Wed, 27 Dec 2023 18:20:37 +0800 Subject: [PATCH] fix #212 --- .../AssetBundleBuilder/BuildAssetInfo.cs | 11 - .../AssetBundleBuilder/BuildMapContext.cs | 5 - .../BaseTasks/TaskCreateReport.cs | 3 +- .../BaseTasks/TaskGetBuildMap.cs | 19 +- .../AssetBundleReporterWindow.cs | 10 - .../Editor/AssetBundleReporter/BuildReport.cs | 5 - .../ReportRedundancyAsset.cs | 35 -- .../ReportRedundancyAsset.cs.meta | 11 - .../ReporterRedundancyListViewer.cs | 317 ------------------ .../ReporterRedundancyListViewer.cs.meta | 11 - .../ReporterRedundancyListViewer.uxml | 11 - .../ReporterRedundancyListViewer.uxml.meta | 10 - 12 files changed, 3 insertions(+), 445 deletions(-) delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs.meta delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.uxml delete mode 100644 Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.uxml.meta diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs index c78ff6c..3584df1 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildAssetInfo.cs @@ -121,17 +121,6 @@ namespace YooAsset.Editor return true; } - /// - /// 判断是否为冗余资源 - /// - public bool IsRedundancyAsset() - { - if (HasBundleName()) - return false; - - return _referenceBundleNames.Count > 1; - } - /// /// 获取关联资源包的数量 /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs index ede340b..cfe0167 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildMapContext.cs @@ -13,11 +13,6 @@ namespace YooAsset.Editor /// private readonly Dictionary _bundleInfoDic = new Dictionary(10000); - /// - /// 冗余的资源列表 - /// - public readonly List RedundancyInfos = new List(1000); - /// /// 未被依赖的资源列表 /// diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs index 15ec061..9754a00 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskCreateReport.cs @@ -107,8 +107,7 @@ namespace YooAsset.Editor buildReport.BundleInfos.Add(reportBundleInfo); } - // 资源列表 - buildReport.RedundancyAssets = new List(buildMapContext.RedundancyInfos); + // 其它资源列表 buildReport.IndependAssets = new List(buildMapContext.IndependAssets); // 序列化文件 diff --git a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs index fbe1202..fb2502c 100644 --- a/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs +++ b/Assets/YooAsset/Editor/AssetBundleBuilder/BuildPipeline/BaseTasks/TaskGetBuildMap.cs @@ -102,22 +102,7 @@ namespace YooAsset.Editor context.AssetFileCount = allBuildAssetInfos.Count; context.Command = collectResult.Command; - // 8. 记录冗余资源 - foreach (var buildAssetInfo in allBuildAssetInfos.Values) - { - if (buildAssetInfo.IsRedundancyAsset()) - { - 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); - } - } - - // 9. 移除不参与构建的资源 + // 8. 移除不参与构建的资源 List removeBuildList = new List(); foreach (var buildAssetInfo in allBuildAssetInfos.Values) { @@ -129,7 +114,7 @@ namespace YooAsset.Editor allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath); } - // 10. 构建资源列表 + // 9. 构建资源列表 var allPackAssets = allBuildAssetInfos.Values.ToList(); if (allPackAssets.Count == 0) { diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs b/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs index ee0d31c..a168b0f 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/AssetBundleReporterWindow.cs @@ -46,7 +46,6 @@ namespace YooAsset.Editor private ReporterSummaryViewer _summaryViewer; private ReporterAssetListViewer _assetListViewer; private ReporterBundleListViewer _bundleListViewer; - private ReporterRedundancyListViewer _redundancyListViewer; private EViewMode _viewMode; private BuildReport _buildReport; @@ -94,10 +93,6 @@ namespace YooAsset.Editor _bundleListViewer = new ReporterBundleListViewer(); _bundleListViewer.InitViewer(); - // 加载试图 - _redundancyListViewer = new ReporterRedundancyListViewer(); - _redundancyListViewer.InitViewer(); - // 显示视图 _viewMode = EViewMode.Summary; _viewModeMenu.text = EViewMode.Summary.ToString(); @@ -125,7 +120,6 @@ namespace YooAsset.Editor _summaryViewer.FillViewData(_buildReport); _assetListViewer.FillViewData(_buildReport, _searchKeyWord); _bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord); - _redundancyListViewer.FillViewData(_buildReport, _searchKeyWord); } private void OnSearchKeyWordChange(ChangeEvent e) { @@ -146,7 +140,6 @@ namespace YooAsset.Editor _summaryViewer.AttachParent(root); _assetListViewer.DetachParent(); _bundleListViewer.DetachParent(); - _redundancyListViewer.DetachParent(); } } private void ViewModeMenuAction1(DropdownMenuAction action) @@ -159,7 +152,6 @@ namespace YooAsset.Editor _summaryViewer.DetachParent(); _assetListViewer.AttachParent(root); _bundleListViewer.DetachParent(); - _redundancyListViewer.DetachParent(); } } private void ViewModeMenuAction2(DropdownMenuAction action) @@ -172,7 +164,6 @@ namespace YooAsset.Editor _summaryViewer.DetachParent(); _assetListViewer.DetachParent(); _bundleListViewer.AttachParent(root); - _redundancyListViewer.DetachParent(); } } private void ViewModeMenuAction3(DropdownMenuAction action) @@ -185,7 +176,6 @@ namespace YooAsset.Editor _summaryViewer.DetachParent(); _assetListViewer.DetachParent(); _bundleListViewer.DetachParent(); - _redundancyListViewer.AttachParent(root); } } private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action) diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs index 9e101f3..ca84a70 100644 --- a/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs +++ b/Assets/YooAsset/Editor/AssetBundleReporter/BuildReport.cs @@ -27,11 +27,6 @@ namespace YooAsset.Editor /// public List BundleInfos = new List(); - /// - /// 冗余的资源列表 - /// - public List RedundancyAssets = new List(); - /// /// 未被依赖的资源列表 /// diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs deleted file mode 100644 index 9ffd045..0000000 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; - -namespace YooAsset.Editor -{ - [Serializable] - public class ReportRedundancyAsset - { - /// - /// 资源路径 - /// - public string AssetPath; - - /// - /// 资源GUID - /// - public string AssetGUID; - - /// - /// 资源类型 - /// - public string AssetType; - - /// - /// 资源文件大小 - /// - public long FileSize; - - /// - /// 冗余的资源包数量 - /// - public int Number; - } -} \ No newline at end of file diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta b/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta deleted file mode 100644 index b2c5230..0000000 --- a/Assets/YooAsset/Editor/AssetBundleReporter/ReportRedundancyAsset.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7fbb7b27f54d3b0439a951348fd9d785 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs b/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs deleted file mode 100644 index f3cde91..0000000 --- a/Assets/YooAsset/Editor/AssetBundleReporter/VisualViewers/ReporterRedundancyListViewer.cs +++ /dev/null @@ -1,317 +0,0 @@ -#if UNITY_2019_4_OR_NEWER -using System; -using System.Linq; -using System.Collections.Generic; -using UnityEditor; -using UnityEngine; -using UnityEditor.UIElements; -using UnityEngine.UIElements; - -namespace YooAsset.Editor -{ - internal class ReporterRedundancyListViewer - { - private enum ESortMode - { - AssetPath, - AssetType, - FileSize, - Number, - } - - private VisualTreeAsset _visualAsset; - private TemplateContainer _root; - - private ToolbarButton _topBar1; - private ToolbarButton _topBar2; - private ToolbarButton _topBar3; - private ToolbarButton _topBar4; - private ListView _assetListView; - - private BuildReport _buildReport; - private string _searchKeyWord; - private ESortMode _sortMode = ESortMode.AssetPath; - private bool _descendingSort = false; - - - /// - /// 初始化页面 - /// - public void InitViewer() - { - // 加载布局文件 - _visualAsset = UxmlLoader.LoadWindowUXML(); - if (_visualAsset == null) - return; - - _root = _visualAsset.CloneTree(); - _root.style.flexGrow = 1f; - - // 顶部按钮栏 - _topBar1 = _root.Q("TopBar1"); - _topBar2 = _root.Q("TopBar2"); - _topBar3 = _root.Q("TopBar3"); - _topBar4 = _root.Q("TopBar4"); - _topBar1.clicked += TopBar1_clicked; - _topBar2.clicked += TopBar2_clicked; - _topBar3.clicked += TopBar3_clicked; - _topBar4.clicked += TopBar4_clicked; - - // 资源列表 - _assetListView = _root.Q("TopListView"); - _assetListView.makeItem = MakeAssetListViewItem; - _assetListView.bindItem = BindAssetListViewItem; - } - - /// - /// 填充页面数据 - /// - public void FillViewData(BuildReport buildReport, string searchKeyWord) - { - _buildReport = buildReport; - _searchKeyWord = searchKeyWord; - RefreshView(); - } - private void RefreshView() - { - _assetListView.Clear(); - _assetListView.ClearSelection(); - _assetListView.itemsSource = FilterAndSortViewItems(); - _assetListView.Rebuild(); - RefreshSortingSymbol(); - } - private List FilterAndSortViewItems() - { - List result = new List(_buildReport.RedundancyAssets.Count); - - // 过滤列表 - foreach (var redundancyInfo in _buildReport.RedundancyAssets) - { - if (string.IsNullOrEmpty(_searchKeyWord) == false) - { - if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false) - continue; - } - result.Add(redundancyInfo); - } - - // 排序列表 - if (_sortMode == ESortMode.AssetPath) - { - if (_descendingSort) - return result.OrderByDescending(a => a.AssetPath).ToList(); - else - return result.OrderBy(a => a.AssetPath).ToList(); - } - else if (_sortMode == ESortMode.AssetType) - { - if (_descendingSort) - return result.OrderByDescending(a => a.AssetType).ToList(); - else - return result.OrderBy(a => a.AssetType).ToList(); - } - else if (_sortMode == ESortMode.FileSize) - { - if (_descendingSort) - return result.OrderByDescending(a => a.FileSize).ToList(); - else - return result.OrderBy(a => a.FileSize).ToList(); - } - else if (_sortMode == ESortMode.Number) - { - if (_descendingSort) - return result.OrderByDescending(a => a.Number).ToList(); - else - return result.OrderBy(a => a.Number).ToList(); - } - else - { - throw new System.NotImplementedException(); - } - } - private void RefreshSortingSymbol() - { - _topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})"; - _topBar2.text = "Asset Type"; - _topBar3.text = "File Size"; - _topBar4.text = "Redundancy Num"; - - if (_sortMode == ESortMode.AssetPath) - { - if (_descendingSort) - _topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↓"; - else - _topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↑"; - } - else if (_sortMode == ESortMode.AssetType) - { - if (_descendingSort) - _topBar2.text = "Asset Type ↓"; - else - _topBar2.text = "Asset Type ↑"; - } - else if (_sortMode == ESortMode.FileSize) - { - if (_descendingSort) - _topBar3.text = "File Size ↓"; - else - _topBar3.text = "File Size ↑"; - } - else if (_sortMode == ESortMode.Number) - { - if (_descendingSort) - _topBar4.text = "Redundancy Num ↓"; - else - _topBar4.text = "Redundancy Num ↑"; - } - else - { - throw new System.NotImplementedException(); - } - } - - /// - /// 挂接到父类页面上 - /// - public void AttachParent(VisualElement parent) - { - parent.Add(_root); - } - - /// - /// 从父类页面脱离开 - /// - public void DetachParent() - { - _root.RemoveFromHierarchy(); - } - - - // 资源列表相关 - private VisualElement MakeAssetListViewItem() - { - VisualElement element = new VisualElement(); - element.style.flexDirection = FlexDirection.Row; - - { - var label = new Label(); - label.name = "Label1"; - label.style.unityTextAlign = TextAnchor.MiddleLeft; - label.style.marginLeft = 3f; - label.style.flexGrow = 1f; - label.style.width = 280; - element.Add(label); - } - - { - var label = new Label(); - label.name = "Label2"; - label.style.unityTextAlign = TextAnchor.MiddleLeft; - label.style.marginLeft = 3f; - label.style.flexGrow = 0; - label.style.width = 200; - element.Add(label); - } - - { - var label = new Label(); - label.name = "Label3"; - label.style.unityTextAlign = TextAnchor.MiddleLeft; - label.style.marginLeft = 3f; - label.style.flexGrow = 0; - label.style.width = 125; - element.Add(label); - } - - { - var label = new Label(); - label.name = "Label4"; - label.style.unityTextAlign = TextAnchor.MiddleLeft; - label.style.marginLeft = 3f; - label.style.flexGrow = 0; - label.style.width = 125; - element.Add(label); - } - - return element; - } - private void BindAssetListViewItem(VisualElement element, int index) - { - var sourceData = _assetListView.itemsSource as List; - var redundancyInfo = sourceData[index]; - - // Asset Path - var label1 = element.Q