浼樺寲
This commit is contained in:
parent
7fbdc734d9
commit
1571dfc6c2
177
CHANGELOG.md
177
CHANGELOG.md
@ -2,6 +2,183 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.2-preview] - 2025-02-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- (2.3.1) 修复小游戏平台下载器不生效的问题。
|
||||
- (#480) 修复了Unity工程打包导出时的报错。
|
||||
|
||||
### Added
|
||||
|
||||
- 下载器新增参数:recursiveDownload
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包
|
||||
public ResourceDownloaderOperation CreateBundleDownloader()
|
||||
```
|
||||
|
||||
- 新增CustomPlayMode模式
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 自定义运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class CustomPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件系统初始化参数列表
|
||||
/// 注意:列表最后一个元素作为主文件系统!
|
||||
/// </summary>
|
||||
public List<FileSystemParameters> FileSystemParameterList;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.1-preview] - 2025-02-25
|
||||
|
||||
**资源加载依赖计算方式还原为了1.5x版本的模式,只加载资源对象实际依赖的资源包,不再以资源对象所在资源包的依赖关系为加载标准**。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化OperationSystem的更新机制,异步加载的耗时降低了50%。
|
||||
- 优化了Debugger窗口的显示页面,BundleView页面增加资源包的引用列表。
|
||||
- 优化了Reporter窗口的显示页面。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了怀旧依赖模式下,TAG传染不正确的问题。
|
||||
|
||||
## [2.3.0-preview] - 2025-02-19
|
||||
|
||||
### Improvements
|
||||
|
||||
资源收集窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
资源扫描窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了UIElements扩展类ReorderableListView
|
||||
|
||||
- 新增初始化方法
|
||||
|
||||
```csharp
|
||||
public class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置异步系统参数,快速启动模式的开关
|
||||
/// 注意:该模式默认开启
|
||||
/// </summary>
|
||||
public static void SetOperationSystemQuickStartMode(bool state)
|
||||
}
|
||||
```
|
||||
|
||||
- 新增打包构建参数
|
||||
|
||||
```csharp
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 旧版依赖模式
|
||||
/// 说明:兼容YooAssets1.5.x版本
|
||||
/// </summary>
|
||||
public bool LegacyDependency = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#472) 修复了Unity6平台,TableView视图无法显示问题。
|
||||
- 修复了微信小游戏和抖音小游戏未正确使用插件的卸载方法。
|
||||
|
||||
## [2.2.12] - 2025-02-14
|
||||
|
||||
### Improvements
|
||||
|
||||
- WebGL网页平台支持文件加密。
|
||||
- 微信小游戏平台支持文件加密。
|
||||
- 抖音小游戏平台支持文件加密。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#466) 修复了微信小游戏文件系统查询机制不生效!
|
||||
- (#341) 修复了微信小游戏的下载进度异常问题。
|
||||
- (#471) 修复了Unity2019,Unity2020平台上,TableView视图无法显示的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了ResourcePackage.UnloadAllAssetsAsync(UnloadAllAssetsOptions options)方法
|
||||
|
||||
```csharp
|
||||
public sealed class UnloadAllAssetsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
||||
/// </summary>
|
||||
public bool ReleaseAllHandles = true;
|
||||
|
||||
/// <summary>
|
||||
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
||||
/// </summary>
|
||||
public bool LockLoadOperation = true;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.2.11] - 2025-02-10
|
||||
|
||||
### Improvements
|
||||
|
||||
- AssetArtScanner配置和生成报告的容错性检测。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#465) 修复了特殊情况下,没有配置资源包文件后缀名构建失败的问题。
|
||||
- (#468) 修复了安卓平台二次启动加载原生文件或加密文件失败的问题。
|
||||
|
||||
## [2.2.10] - 2025-02-08
|
||||
|
||||
### Improvements
|
||||
|
||||
- 新增了可扩展的AssetArtScanner资源扫描工具,详细请见官方说明文档。
|
||||
- 优化了AssetBundleReporter页面。
|
||||
- 优化了AssetBundleDebugger页面。
|
||||
- 优化了微信小游戏文件系统的缓存查询机制。
|
||||
- 优化了抖音小游戏文件系统的缓存查询机制。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#447) 修复了Unity2019平台代码编译错误问题。
|
||||
- (#456) 修复了在Package未激活有效清单之前,无法销毁的问题。
|
||||
- (#452) 修复了内置文件系统类NeedPack方法总是返回TRUE的问题。
|
||||
- (#424) 适配了Unity6000版本替换了过时方法。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了SBP构建管线构建参数:BuiltinShadersBundleName
|
||||
|
||||
- 新增了SBP构建管线构建参数:MonoScriptsBundleName
|
||||
|
||||
- 新增了全局构建管线构建参数:SingleReferencedPackAlone
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 对单独引用的共享资源进行独立打包
|
||||
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||
/// </summary>
|
||||
public bool SingleReferencedPackAlone = true;
|
||||
```
|
||||
|
||||
- 新增了内置文件系统初始化参数:COPY_BUILDIN_PACKAGE_MANIFEST
|
||||
|
||||
```csharp
|
||||
// 内置文件系统初始化的时候,自动拷贝内置清单到沙盒目录。
|
||||
var systemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
systemParameters.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
|
||||
```
|
||||
|
||||
## [2.2.9] - 2025-01-14
|
||||
|
||||
### Fixed
|
||||
|
8
Editor/AssetArtReporter.meta
Normal file
8
Editor/AssetArtReporter.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bdbb4647038dcc842802f546c2fedc83
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
624
Editor/AssetArtReporter/AssetArtReporterWindow.cs
Normal file
624
Editor/AssetArtReporter/AssetArtReporterWindow.cs
Normal file
@ -0,0 +1,624 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtReporterWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetArt Reporter", false, 302)]
|
||||
public static AssetArtReporterWindow OpenWindow()
|
||||
{
|
||||
AssetArtReporterWindow window = GetWindow<AssetArtReporterWindow>("AssetArt Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
return window;
|
||||
}
|
||||
|
||||
private class ElementTableData : DefaultTableData
|
||||
{
|
||||
public ReportElement Element;
|
||||
}
|
||||
private class PassesBtnCell : ITableCell, IComparable
|
||||
{
|
||||
public object CellValue { set; get; }
|
||||
public string SearchTag { private set; get; }
|
||||
public ReportElement Element
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ReportElement)CellValue;
|
||||
}
|
||||
}
|
||||
|
||||
public PassesBtnCell(string searchTag, ReportElement element)
|
||||
{
|
||||
SearchTag = searchTag;
|
||||
CellValue = element;
|
||||
}
|
||||
public object GetDisplayObject()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other is PassesBtnCell cell)
|
||||
{
|
||||
return this.Element.Passes.CompareTo(cell.Element.Passes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
private class WhiteListBtnCell : ITableCell, IComparable
|
||||
{
|
||||
public object CellValue { set; get; }
|
||||
public string SearchTag { private set; get; }
|
||||
public ReportElement Element
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ReportElement)CellValue;
|
||||
}
|
||||
}
|
||||
|
||||
public WhiteListBtnCell(string searchTag, ReportElement element)
|
||||
{
|
||||
SearchTag = searchTag;
|
||||
CellValue = element;
|
||||
}
|
||||
public object GetDisplayObject()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other is WhiteListBtnCell cell)
|
||||
{
|
||||
return this.Element.IsWhiteList.CompareTo(cell.Element.IsWhiteList);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ToolbarSearchField _searchField;
|
||||
private Button _showHiddenBtn;
|
||||
private Button _whiteListVisibleBtn;
|
||||
private Button _passesVisibleBtn;
|
||||
private Label _titleLabel;
|
||||
private Label _descLabel;
|
||||
private TableView _elementTableView;
|
||||
|
||||
private ScanReportCombiner _reportCombiner;
|
||||
private string _lastestOpenFolder;
|
||||
private List<ITableData> _sourceDatas;
|
||||
private bool _elementVisibleState = true;
|
||||
private bool _whiteListVisibleState = true;
|
||||
private bool _passesVisibleState = true;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入按钮
|
||||
var importSingleBtn = root.Q<Button>("SingleImportButton");
|
||||
importSingleBtn.clicked += ImportSingleBtn_clicked;
|
||||
var importMultiBtn = root.Q<Button>("MultiImportButton");
|
||||
importMultiBtn.clicked += ImportMultiBtn_clicked;
|
||||
|
||||
// 修复按钮
|
||||
var fixAllBtn = root.Q<Button>("FixAllButton");
|
||||
fixAllBtn.clicked += FixAllBtn_clicked;
|
||||
var fixSelectBtn = root.Q<Button>("FixSelectButton");
|
||||
fixSelectBtn.clicked += FixSelectBtn_clicked;
|
||||
|
||||
// 可见性按钮
|
||||
_showHiddenBtn = root.Q<Button>("ShowHiddenButton");
|
||||
_showHiddenBtn.clicked += ShowHiddenBtn_clicked;
|
||||
_whiteListVisibleBtn = root.Q<Button>("WhiteListVisibleButton");
|
||||
_whiteListVisibleBtn.clicked += WhiteListVisibleBtn_clicked;
|
||||
_passesVisibleBtn = root.Q<Button>("PassesVisibleButton");
|
||||
_passesVisibleBtn.clicked += PassesVsibleBtn_clicked;
|
||||
|
||||
// 文件导出按钮
|
||||
var exportFilesBtn = root.Q<Button>("ExportFilesButton");
|
||||
exportFilesBtn.clicked += ExportFilesBtn_clicked;
|
||||
|
||||
// 搜索过滤
|
||||
_searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
_searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 标题和备注
|
||||
_titleLabel = root.Q<Label>("ReportTitle");
|
||||
_descLabel = root.Q<Label>("ReportDesc");
|
||||
|
||||
// 列表相关
|
||||
_elementTableView = root.Q<TableView>("TopTableView");
|
||||
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
||||
|
||||
_lastestOpenFolder = EditorTools.GetProjectPath();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.SaveChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入单个报告文件
|
||||
/// </summary>
|
||||
public void ImportSingleReprotFile(string filePath)
|
||||
{
|
||||
// 记录本次打开目录
|
||||
_lastestOpenFolder = Path.GetDirectoryName(filePath);
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||
_reportCombiner.Combine(scanReport);
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
private void ImportSingleBtn_clicked()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
ImportSingleReprotFile(selectFilePath);
|
||||
}
|
||||
private void ImportMultiBtn_clicked()
|
||||
{
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("导入报告", _lastestOpenFolder, null);
|
||||
if (string.IsNullOrEmpty(selectFolderPath))
|
||||
return;
|
||||
|
||||
// 记录本次打开目录
|
||||
_lastestOpenFolder = selectFolderPath;
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
string[] files = Directory.GetFiles(selectFolderPath);
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
string extension = System.IO.Path.GetExtension(filePath);
|
||||
if (extension == ".json")
|
||||
{
|
||||
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||
_reportCombiner.Combine(scanReport);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
private void FixAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复全部资源(排除白名单和隐藏元素)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixAll();
|
||||
}
|
||||
}
|
||||
private void FixSelectBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复勾选资源(包含白名单和隐藏元素)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixSelect();
|
||||
}
|
||||
}
|
||||
private void ShowHiddenBtn_clicked()
|
||||
{
|
||||
_elementVisibleState = !_elementVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void WhiteListVisibleBtn_clicked()
|
||||
{
|
||||
_whiteListVisibleState = !_whiteListVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void PassesVsibleBtn_clicked()
|
||||
{
|
||||
_passesVisibleState = !_passesVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void ExportFilesBtn_clicked()
|
||||
{
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("导入所有选中资源", EditorTools.GetProjectPath(), string.Empty);
|
||||
if (string.IsNullOrEmpty(selectFolderPath) == false)
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.ExportFiles(selectFolderPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshToolbar()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
_titleLabel.text = _reportCombiner.ReportTitle;
|
||||
_descLabel.text = _reportCombiner.ReportDesc;
|
||||
|
||||
var enableColor = new Color32(18, 100, 18, 255);
|
||||
var disableColor = new Color32(100, 100, 100, 255);
|
||||
|
||||
if (_elementVisibleState)
|
||||
_showHiddenBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_showHiddenBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
|
||||
if (_whiteListVisibleState)
|
||||
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
|
||||
if (_passesVisibleState)
|
||||
_passesVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_passesVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
}
|
||||
private void FillTableView()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
_elementTableView.ClearAll(true, true);
|
||||
|
||||
// 眼睛标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(20);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var toggle = new DisplayToggle();
|
||||
toggle.text = string.Empty;
|
||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
||||
return toggle;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var toggle = element as DisplayToggle;
|
||||
toggle.userData = data;
|
||||
var tableData = data as ElementTableData;
|
||||
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
||||
toggle.RefreshIcon();
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 通过标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(70);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("通过", "通过", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var button = new Button();
|
||||
button.text = "通过";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.SetEnabled(false);
|
||||
return button;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
Button button = element as Button;
|
||||
var elementTableData = data as ElementTableData;
|
||||
if (elementTableData.Element.Passes)
|
||||
{
|
||||
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||
button.text = "通过";
|
||||
}
|
||||
else
|
||||
{
|
||||
button.style.backgroundColor = new StyleColor(new Color32(137, 0, 0, 255));
|
||||
button.text = "失败";
|
||||
}
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("通过");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 白名单标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(70);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("白名单", "白名单", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
Button button = new Button();
|
||||
button.text = "白名单";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.clickable.clickedWithEventInfo += OnClickWhitListButton;
|
||||
return button;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
Button button = element as Button;
|
||||
button.userData = data;
|
||||
var elementTableData = data as ElementTableData;
|
||||
if (elementTableData.Element.IsWhiteList)
|
||||
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||
else
|
||||
button.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("白名单");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 选中标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(20);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("选中框", string.Empty, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var toggle = new Toggle();
|
||||
toggle.text = string.Empty;
|
||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); });
|
||||
return toggle;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var toggle = element as Toggle;
|
||||
toggle.userData = data;
|
||||
var tableData = data as ElementTableData;
|
||||
toggle.SetValueWithoutNotify(tableData.Element.IsSelected);
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// 自定义标题栏
|
||||
foreach (var header in _reportCombiner.Headers)
|
||||
{
|
||||
var columnStyle = new ColumnStyle(header.Width, header.MinWidth, header.MaxWidth);
|
||||
columnStyle.Stretchable = header.Stretchable;
|
||||
columnStyle.Searchable = header.Searchable;
|
||||
columnStyle.Sortable = header.Sortable;
|
||||
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_reportCombiner.Elements.Count);
|
||||
foreach (var element in _reportCombiner.Elements)
|
||||
{
|
||||
var tableData = new ElementTableData();
|
||||
tableData.Element = element;
|
||||
|
||||
// 固定标题
|
||||
tableData.AddButtonCell("眼睛框");
|
||||
tableData.AddCell(new PassesBtnCell("通过", element));
|
||||
tableData.AddCell(new WhiteListBtnCell("白名单", element));
|
||||
tableData.AddButtonCell("选中框");
|
||||
|
||||
// 自定义标题
|
||||
foreach (var scanInfo in element.ScanInfos)
|
||||
{
|
||||
var header = _reportCombiner.GetHeader(scanInfo.HeaderTitle);
|
||||
if (header.HeaderType == EHeaderType.AssetPath)
|
||||
{
|
||||
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.LongValue)
|
||||
{
|
||||
long value = Convert.ToInt64(scanInfo.ScanInfo);
|
||||
tableData.AddLongValueCell(scanInfo.HeaderTitle, value);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
double value = Convert.ToDouble(scanInfo.ScanInfo);
|
||||
tableData.AddDoubleValueCell(scanInfo.HeaderTitle, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(header.HeaderType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
_sourceDatas.Add(tableData);
|
||||
}
|
||||
_elementTableView.itemsSource = _sourceDatas;
|
||||
}
|
||||
private void RebuildView()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
string searchKeyword = _searchField.value;
|
||||
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyword);
|
||||
|
||||
// 开关匹配
|
||||
foreach (var tableData in _sourceDatas)
|
||||
{
|
||||
var elementTableData = tableData as ElementTableData;
|
||||
if (_elementVisibleState == false && elementTableData.Element.Hidden)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
if (_passesVisibleState == false && elementTableData.Element.Passes)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
if (_whiteListVisibleState == false && elementTableData.Element.IsWhiteList)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 重建视图
|
||||
_elementTableView.RebuildView();
|
||||
}
|
||||
|
||||
private void OnClickTableViewItem(PointerDownEvent evt, ITableData tableData)
|
||||
{
|
||||
// 双击后检视对应的资源
|
||||
if (evt.clickCount == 2)
|
||||
{
|
||||
foreach (var cell in tableData.Cells)
|
||||
{
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
RebuildView();
|
||||
}
|
||||
private void OnSelectToggleValueChange(Toggle toggle, ChangeEvent<bool> e)
|
||||
{
|
||||
// 处理自身
|
||||
toggle.SetValueWithoutNotify(e.newValue);
|
||||
|
||||
// 记录数据
|
||||
var elementTableData = toggle.userData as ElementTableData;
|
||||
elementTableData.Element.IsSelected = e.newValue;
|
||||
|
||||
// 处理多选目标
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.IsSelected = e.newValue;
|
||||
}
|
||||
|
||||
// 重绘视图
|
||||
RebuildView();
|
||||
}
|
||||
private void OnDisplayToggleValueChange(DisplayToggle toggle, ChangeEvent<bool> e)
|
||||
{
|
||||
toggle.RefreshIcon();
|
||||
|
||||
// 处理自身
|
||||
toggle.SetValueWithoutNotify(e.newValue);
|
||||
|
||||
// 记录数据
|
||||
var elementTableData = toggle.userData as ElementTableData;
|
||||
elementTableData.Element.Hidden = e.newValue;
|
||||
|
||||
// 处理多选目标
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.Hidden = e.newValue;
|
||||
}
|
||||
|
||||
// 重绘视图
|
||||
RebuildView();
|
||||
}
|
||||
private void OnClickWhitListButton(EventBase evt)
|
||||
{
|
||||
// 刷新点击的按钮
|
||||
Button button = evt.target as Button;
|
||||
var elementTableData = button.userData as ElementTableData;
|
||||
elementTableData.Element.IsWhiteList = !elementTableData.Element.IsWhiteList;
|
||||
|
||||
// 刷新框选的按钮
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
if (selectedItems.Count() > 1)
|
||||
{
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.IsWhiteList = selectElement.Element.IsWhiteList;
|
||||
}
|
||||
}
|
||||
|
||||
RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2fb1b9a2a91f1af4a86acfcfac424e0b
|
||||
guid: 4048f85b9ff1f424a89a9d6109e6faaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
22
Editor/AssetArtReporter/AssetArtReporterWindow.uxml
Normal file
22
Editor/AssetArtReporter/AssetArtReporterWindow.uxml
Normal file
@ -0,0 +1,22 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||
<ui:Button text="Fix Select" display-tooltip-when-elided="true" name="FixSelectButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Fix All" display-tooltip-when-elided="true" name="FixAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Export Select" display-tooltip-when-elided="true" name="ExportFilesButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text=" Multi-Import" display-tooltip-when-elided="true" name="MultiImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="SingleImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="标题" display-tooltip-when-elided="true" name="ReportTitle" style="height: 16px; -unity-font-style: bold; -unity-text-align: middle-center;" />
|
||||
<ui:Label text="说明" display-tooltip-when-elided="true" name="ReportDesc" style="-unity-text-align: upper-left; -unity-font-style: bold; background-color: rgb(42, 42, 42); min-height: 50px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; white-space: normal;" />
|
||||
</ui:VisualElement>
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||
<ui:Button text="显示隐藏元素" display-tooltip-when-elided="true" name="ShowHiddenButton" style="width: 100px;" />
|
||||
<ui:Button text="显示通过元素" display-tooltip-when-elided="true" name="PassesVisibleButton" style="width: 100px;" />
|
||||
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="AssetGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableView name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
10
Editor/AssetArtReporter/AssetArtReporterWindow.uxml.meta
Normal file
10
Editor/AssetArtReporter/AssetArtReporterWindow.uxml.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b87fc70b750616849942173af3bdfd90
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
26
Editor/AssetArtReporter/EHeaderType.cs
Normal file
26
Editor/AssetArtReporter/EHeaderType.cs
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public enum EHeaderType
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
AssetPath,
|
||||
|
||||
/// <summary>
|
||||
/// 字符串
|
||||
/// </summary>
|
||||
StringValue,
|
||||
|
||||
/// <summary>
|
||||
/// 整数数值
|
||||
/// </summary>
|
||||
LongValue,
|
||||
|
||||
/// <summary>
|
||||
/// 浮点数数值
|
||||
/// </summary>
|
||||
DoubleValue,
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84c10fd3507a1c24a9043aebb72db5f5
|
||||
guid: 97cd7d0d616708e42bc53ed7d88718c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
88
Editor/AssetArtReporter/ReportElement.cs
Normal file
88
Editor/AssetArtReporter/ReportElement.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportElement
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID(白名单存储对象)
|
||||
/// </summary>
|
||||
public string GUID;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描是否通过
|
||||
/// </summary>
|
||||
public bool Passes = true;
|
||||
|
||||
/// <summary>
|
||||
/// 反馈的信息列表
|
||||
/// </summary>
|
||||
public List<ReportScanInfo> ScanInfos = new List<ReportScanInfo>();
|
||||
|
||||
|
||||
public ReportElement(string guid)
|
||||
{
|
||||
GUID = guid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, string value)
|
||||
{
|
||||
var reportScanInfo = new ReportScanInfo(headerTitle, value);
|
||||
ScanInfos.Add(reportScanInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, long value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, double value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取扫描信息
|
||||
/// </summary>
|
||||
public ReportScanInfo GetScanInfo(string headerTitle)
|
||||
{
|
||||
foreach (var scanInfo in ScanInfos)
|
||||
{
|
||||
if (scanInfo.HeaderTitle == headerTitle)
|
||||
return scanInfo;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportScanInfo)} : {headerTitle}");
|
||||
return null;
|
||||
}
|
||||
|
||||
#region 临时字段
|
||||
/// <summary>
|
||||
/// 是否在列表里选中
|
||||
/// </summary>
|
||||
public bool IsSelected { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否在白名单里
|
||||
/// </summary>
|
||||
public bool IsWhiteList { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否隐藏元素
|
||||
/// </summary>
|
||||
public bool Hidden { set; get; }
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc10550f17aaeb14795135a51444de1c
|
||||
guid: d61f7ee1a8215bf438071055f0a9cb09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
128
Editor/AssetArtReporter/ReportHeader.cs
Normal file
128
Editor/AssetArtReporter/ReportHeader.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportHeader
|
||||
{
|
||||
public const int MaxValue = 8388608;
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string HeaderTitle;
|
||||
|
||||
/// <summary>
|
||||
/// 标题宽度
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// 单元列最小宽度
|
||||
/// </summary>
|
||||
public int MinWidth = 50;
|
||||
|
||||
/// <summary>
|
||||
/// 单元列最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 可伸缩选项
|
||||
/// </summary>
|
||||
public bool Stretchable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 可搜索选项
|
||||
/// </summary>
|
||||
public bool Searchable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 可排序选项
|
||||
/// </summary>
|
||||
public bool Sortable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
public EHeaderType HeaderType = EHeaderType.StringValue;
|
||||
|
||||
|
||||
public ReportHeader(string headerTitle, int width)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public ReportHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
|
||||
public ReportHeader SetMinWidth(int value)
|
||||
{
|
||||
MinWidth = value;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetMaxWidth(int value)
|
||||
{
|
||||
MaxWidth = value;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetStretchable()
|
||||
{
|
||||
Stretchable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetSearchable()
|
||||
{
|
||||
Searchable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetSortable()
|
||||
{
|
||||
Sortable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetHeaderType(EHeaderType value)
|
||||
{
|
||||
HeaderType = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测数值有效性
|
||||
/// </summary>
|
||||
public void CheckValueValid(string value)
|
||||
{
|
||||
if (HeaderType == EHeaderType.AssetPath)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
if (double.TryParse(value, out double doubleValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid double value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.LongValue)
|
||||
{
|
||||
if (long.TryParse(value, out long longValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid long value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(HeaderType.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fbbce8ae4b0d0784683413d6466d27f8
|
||||
guid: 3be8b45a77bb720478379c26da3aa68a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
26
Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
26
Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportScanInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string HeaderTitle;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描反馈的信息
|
||||
/// </summary>
|
||||
public string ScanInfo;
|
||||
|
||||
public ReportScanInfo(string headerTitle, string scanInfo)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
ScanInfo = scanInfo;
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtReporter/ReportScanInfo.cs.meta
Normal file
11
Editor/AssetArtReporter/ReportScanInfo.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02caa7ae84ee8294a8904a5aaed420ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
118
Editor/AssetArtReporter/ScanReport.cs
Normal file
118
Editor/AssetArtReporter/ScanReport.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ScanReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件签名(自动填写)
|
||||
/// </summary>
|
||||
public string FileSign;
|
||||
|
||||
/// <summary>
|
||||
/// 文件版本(自动填写)
|
||||
/// </summary>
|
||||
public string FileVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 模式类型(自动填写)
|
||||
/// </summary>
|
||||
public string SchemaType;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器GUID(自动填写)
|
||||
/// </summary>
|
||||
public string ScannerGUID;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报告名称
|
||||
/// </summary>
|
||||
public string ReportName;
|
||||
|
||||
/// <summary>
|
||||
/// 报告介绍
|
||||
/// </summary>
|
||||
public string ReportDesc;
|
||||
|
||||
/// <summary>
|
||||
/// 报告的标题列表
|
||||
/// </summary>
|
||||
public List<ReportHeader> ReportHeaders = new List<ReportHeader>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描的元素列表
|
||||
/// </summary>
|
||||
public List<ReportElement> ReportElements = new List<ReportElement>();
|
||||
|
||||
|
||||
public ScanReport(string reportName, string reportDesc)
|
||||
{
|
||||
ReportName = reportName;
|
||||
ReportDesc = reportDesc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width, minWidth, maxWidth);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测错误
|
||||
/// </summary>
|
||||
public void CheckError()
|
||||
{
|
||||
// 检测标题
|
||||
Dictionary<string, ReportHeader> headerMap = new Dictionary<string, ReportHeader>();
|
||||
foreach (var header in ReportHeaders)
|
||||
{
|
||||
string headerTitle = header.HeaderTitle;
|
||||
if (headerMap.ContainsKey(headerTitle))
|
||||
throw new Exception($"The header title {headerTitle} already exists !");
|
||||
else
|
||||
headerMap.Add(headerTitle, header);
|
||||
}
|
||||
|
||||
// 检测扫描元素
|
||||
HashSet<string> elementMap = new HashSet<string>();
|
||||
foreach (var element in ReportElements)
|
||||
{
|
||||
if (string.IsNullOrEmpty(element.GUID))
|
||||
throw new Exception($"The report element GUID is null or empty !");
|
||||
|
||||
if (elementMap.Contains(element.GUID))
|
||||
throw new Exception($"The report element GUID already exists ! {element.GUID}");
|
||||
else
|
||||
elementMap.Add(element.GUID);
|
||||
|
||||
foreach (var scanInfo in element.ScanInfos)
|
||||
{
|
||||
if (headerMap.ContainsKey(scanInfo.HeaderTitle) == false)
|
||||
throw new Exception($"The report element header {scanInfo.HeaderTitle} is missing !");
|
||||
|
||||
// 检测数值有效性
|
||||
var header = headerMap[scanInfo.HeaderTitle];
|
||||
header.CheckValueValid(scanInfo.ScanInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
11
Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 650e3e4af4ede2a4eb2471c30e7820bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
221
Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
221
Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
@ -0,0 +1,221 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源扫描报告合并器
|
||||
/// 说明:相同类型的报告可以合并查看
|
||||
/// </summary>
|
||||
public class ScanReportCombiner
|
||||
{
|
||||
/// <summary>
|
||||
/// 模式类型
|
||||
/// </summary>
|
||||
public string SchemaType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告标题
|
||||
/// </summary>
|
||||
public string ReportTitle { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告介绍
|
||||
/// </summary>
|
||||
public string ReportDesc { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题列表
|
||||
/// </summary>
|
||||
public List<ReportHeader> Headers = new List<ReportHeader>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描结果
|
||||
/// </summary>
|
||||
public readonly List<ReportElement> Elements = new List<ReportElement>(10000);
|
||||
private readonly Dictionary<string, ScanReport> _combines = new Dictionary<string, ScanReport>(100);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 合并报告文件
|
||||
/// 注意:模式不同的报告文件会合并失败!
|
||||
/// </summary>
|
||||
public bool Combine(ScanReport scanReport)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scanReport.SchemaType))
|
||||
{
|
||||
Debug.LogError("Scan report schema type is null or empty !");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(SchemaType))
|
||||
{
|
||||
SchemaType = scanReport.SchemaType;
|
||||
ReportTitle = scanReport.ReportName;
|
||||
ReportDesc = scanReport.ReportDesc;
|
||||
Headers = scanReport.ReportHeaders;
|
||||
}
|
||||
|
||||
if (SchemaType != scanReport.SchemaType)
|
||||
{
|
||||
Debug.LogWarning($"Scan report has different schema type!{scanReport.SchemaType} != {SchemaType}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_combines.ContainsKey(scanReport.ScannerGUID))
|
||||
{
|
||||
Debug.LogWarning($"Scan report has already existed : {scanReport.ScannerGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
_combines.Add(scanReport.ScannerGUID, scanReport);
|
||||
CombineInternal(scanReport);
|
||||
return true;
|
||||
}
|
||||
private void CombineInternal(ScanReport scanReport)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
List<ReportElement> elements = scanReport.ReportElements;
|
||||
|
||||
// 设置白名单
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (scanner.CheckWhiteList(element.GUID))
|
||||
element.IsWhiteList = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加到集合
|
||||
Elements.AddRange(elements);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的标题类
|
||||
/// </summary>
|
||||
public ReportHeader GetHeader(string headerTitle)
|
||||
{
|
||||
foreach (var header in Headers)
|
||||
{
|
||||
if (header.HeaderTitle == headerTitle)
|
||||
return header;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportHeader)} : {headerTitle}");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出选中文件
|
||||
/// </summary>
|
||||
public void ExportFiles(string exportFolderPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(exportFolderPath))
|
||||
return;
|
||||
|
||||
foreach (var element in Elements)
|
||||
{
|
||||
if (element.IsSelected)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(element.GUID);
|
||||
if (string.IsNullOrEmpty(assetPath) == false)
|
||||
{
|
||||
string destPath = Path.Combine(exportFolderPath, assetPath);
|
||||
EditorTools.CopyFile(assetPath, destPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存改变数据
|
||||
/// </summary>
|
||||
public void SaveChange()
|
||||
{
|
||||
// 存储白名单
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
List<string> whiteList = new List<string>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.IsWhiteList)
|
||||
whiteList.Add(element.GUID);
|
||||
}
|
||||
whiteList.Sort();
|
||||
scanner.WhiteList = whiteList;
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复所有元素
|
||||
/// 注意:排除白名单和隐藏元素
|
||||
/// </summary>
|
||||
public void FixAll()
|
||||
{
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.Passes || element.IsWhiteList || element.Hidden)
|
||||
continue;
|
||||
fixList.Add(element);
|
||||
}
|
||||
FixInternal(scannerGUID, fixList);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复选定元素
|
||||
/// 注意:包含白名单和隐藏元素
|
||||
/// </summary>
|
||||
public void FixSelect()
|
||||
{
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.Passes)
|
||||
continue;
|
||||
if (element.IsSelected)
|
||||
fixList.Add(element);
|
||||
}
|
||||
FixInternal(scannerGUID, fixList);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixInternal(string scannerGUID, List<ReportElement> fixList)
|
||||
{
|
||||
AssetArtScanner scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
var schema = scanner.LoadSchema();
|
||||
if (schema != null)
|
||||
{
|
||||
schema.FixResult(fixList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtReporter/ScanReportCombiner.cs.meta
Normal file
11
Editor/AssetArtReporter/ScanReportCombiner.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8524c3deb9b27fe4e8e63f15b9ffaaa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
54
Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
54
Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScanReportConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入JSON报告文件
|
||||
/// </summary>
|
||||
public static ScanReport ImportJsonConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
string jsonData = FileUtility.ReadAllText(filePath);
|
||||
ScanReport report = JsonUtility.FromJson<ScanReport>(jsonData);
|
||||
|
||||
// 检测配置文件的签名
|
||||
if (report.FileSign != ScannerDefine.ReportFileSign)
|
||||
throw new Exception($"导入的报告文件无法识别 : {filePath}");
|
||||
|
||||
// 检测报告文件的版本
|
||||
if (report.FileVersion != ScannerDefine.ReportFileVersion)
|
||||
throw new Exception($"报告文件的版本不匹配 : {report.FileVersion} != {ScannerDefine.ReportFileVersion}");
|
||||
|
||||
// 检测标题数和内容是否匹配
|
||||
foreach (var element in report.ReportElements)
|
||||
{
|
||||
if (element.ScanInfos.Count != report.ReportHeaders.Count)
|
||||
{
|
||||
throw new Exception($"报告的标题数和内容不匹配!");
|
||||
}
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出JSON报告文件
|
||||
/// </summary>
|
||||
public static void ExportJsonConfig(string savePath, ScanReport scanReport)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
string json = JsonUtility.ToJson(scanReport, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtReporter/ScanReportConfig.cs.meta
Normal file
11
Editor/AssetArtReporter/ScanReportConfig.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 694cf47ade54f2b4fa6e618c1310c476
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Editor/AssetArtScanner.meta
Normal file
8
Editor/AssetArtScanner.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bc1ecc3b72dfc34782fb6926d679f92
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
13
Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描目录
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/AssetArtCollector.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtCollector.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e7252b59455e5c45af0041ccd24b234
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
132
Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
132
Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtScanner
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器GUID
|
||||
/// </summary>
|
||||
public string ScannerGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器名称
|
||||
/// </summary>
|
||||
public string ScannerName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器描述
|
||||
/// </summary>
|
||||
public string ScannerDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描模式
|
||||
/// 注意:文件路径或文件GUID
|
||||
/// </summary>
|
||||
public string ScannerSchema = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 存储目录
|
||||
/// </summary>
|
||||
public string SaveDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集列表
|
||||
/// </summary>
|
||||
public List<AssetArtCollector> Collectors = new List<AssetArtCollector>();
|
||||
|
||||
/// <summary>
|
||||
/// 白名单
|
||||
/// </summary>
|
||||
public List<string> WhiteList = new List<string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测关键字匹配
|
||||
/// </summary>
|
||||
public bool CheckKeyword(string keyword)
|
||||
{
|
||||
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在白名单里
|
||||
/// </summary>
|
||||
public bool CheckWhiteList(string guid)
|
||||
{
|
||||
return WhiteList.Contains(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerName))
|
||||
throw new Exception($"Scanner name is null or empty !");
|
||||
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
throw new Exception($"Scanner {ScannerName} schema is null !");
|
||||
|
||||
if (string.IsNullOrEmpty(SaveDirectory) == false)
|
||||
{
|
||||
if (Directory.Exists(SaveDirectory) == false)
|
||||
throw new Exception($"Scanner {ScannerName} save directory is invalid : {SaveDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载扫描模式实例
|
||||
/// </summary>
|
||||
public ScannerSchema LoadSchema()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
return null;
|
||||
|
||||
string filePath;
|
||||
if (ScannerSchema.StartsWith("Assets/"))
|
||||
{
|
||||
filePath = ScannerSchema;
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = ScannerSchema;
|
||||
filePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
}
|
||||
|
||||
var schema = AssetDatabase.LoadMainAssetAtPath(filePath) as ScannerSchema;
|
||||
if (schema == null)
|
||||
Debug.LogWarning($"Failed load scanner schema : {filePath}");
|
||||
return schema;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行扫描器生成报告类
|
||||
/// </summary>
|
||||
public ScanReport RunScanner()
|
||||
{
|
||||
if (Collectors.Count == 0)
|
||||
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
|
||||
|
||||
ScannerSchema schema = LoadSchema();
|
||||
if (schema == null)
|
||||
throw new Exception($"Failed to load schema : {ScannerSchema}");
|
||||
|
||||
var report = schema.RunScanner(this);
|
||||
report.FileSign = ScannerDefine.ReportFileSign;
|
||||
report.FileVersion = ScannerDefine.ReportFileVersion;
|
||||
report.SchemaType = schema.GetType().FullName;
|
||||
report.ScannerGUID = ScannerGUID;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/AssetArtScanner.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtScanner.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c63683b07b7a2454b93539ae6b9f32ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
85
Editor/AssetArtScanner/AssetArtScannerConfig.cs
Normal file
85
Editor/AssetArtScanner/AssetArtScannerConfig.cs
Normal file
@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerConfig
|
||||
{
|
||||
public class ConfigWrapper
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件签名
|
||||
/// </summary>
|
||||
public string FileSign;
|
||||
|
||||
/// <summary>
|
||||
/// 文件版本
|
||||
/// </summary>
|
||||
public string FileVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入JSON配置文件
|
||||
/// </summary>
|
||||
public static void ImportJsonConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
string json = FileUtility.ReadAllText(filePath);
|
||||
ConfigWrapper setting = JsonUtility.FromJson<ConfigWrapper>(json);
|
||||
|
||||
// 检测配置文件的签名
|
||||
if (setting.FileSign != ScannerDefine.SettingFileSign)
|
||||
throw new Exception($"导入的配置文件无法识别 : {filePath}");
|
||||
|
||||
// 检测配置文件的版本
|
||||
if (setting.FileVersion != ScannerDefine.SettingFileVersion)
|
||||
throw new Exception($"配置文件的版本不匹配 : {setting.FileVersion} != {ScannerDefine.SettingFileVersion}");
|
||||
|
||||
// 检测配置合法性
|
||||
HashSet<string> scanGUIDs = new HashSet<string>();
|
||||
foreach (var sacnner in setting.Scanners)
|
||||
{
|
||||
if (scanGUIDs.Contains(sacnner.ScannerGUID))
|
||||
{
|
||||
throw new Exception($"Scanner {sacnner.ScannerName} GUID is existed : {sacnner.ScannerGUID} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
scanGUIDs.Add(sacnner.ScannerGUID);
|
||||
}
|
||||
}
|
||||
|
||||
AssetArtScannerSettingData.Setting.Scanners = setting.Scanners;
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出JSON配置文件
|
||||
/// </summary>
|
||||
public static void ExportJsonConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
ConfigWrapper wrapper = new ConfigWrapper();
|
||||
wrapper.FileSign = ScannerDefine.SettingFileSign;
|
||||
wrapper.FileVersion = ScannerDefine.SettingFileVersion;
|
||||
wrapper.Scanners = AssetArtScannerSettingData.Setting.Scanners;
|
||||
|
||||
string json = JsonUtility.ToJson(wrapper, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/AssetArtScannerConfig.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtScannerConfig.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bed1ef72d1c03e848a41d5ea115e9870
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
68
Editor/AssetArtScanner/AssetArtScannerSetting.cs
Normal file
68
Editor/AssetArtScanner/AssetArtScannerSetting.cs
Normal file
@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
|
||||
/// <summary>
|
||||
/// 开始扫描
|
||||
/// </summary>
|
||||
public ScannerResult BeginScan(string scannerGUID)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取扫描器配置
|
||||
var scanner = GetScanner(scannerGUID);
|
||||
if (scanner == null)
|
||||
throw new Exception($"Invalid scanner GUID : {scannerGUID}");
|
||||
|
||||
// 检测配置合法性
|
||||
scanner.CheckConfigError();
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的扫描器
|
||||
/// </summary>
|
||||
public AssetArtScanner GetScanner(string scannerGUID)
|
||||
{
|
||||
foreach (var scanner in Scanners)
|
||||
{
|
||||
if (scanner.ScannerGUID == scannerGUID)
|
||||
return scanner;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/AssetArtScannerSetting.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtScannerSetting.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84df5e62e3f1b6746a1263e076b003e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
161
Editor/AssetArtScanner/AssetArtScannerSettingData.cs
Normal file
161
Editor/AssetArtScanner/AssetArtScannerSettingData.cs
Normal file
@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSettingData
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
static AssetArtScannerSettingData()
|
||||
{
|
||||
}
|
||||
|
||||
private static AssetArtScannerSetting _setting = null;
|
||||
public static AssetArtScannerSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
_setting = SettingLoader.LoadSettingData<AssetArtScannerSetting>();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetArtScannerSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.Scanners.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll()
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll(string keyword)
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyword) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(keyword) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描单项
|
||||
/// </summary>
|
||||
public static ScannerResult Scan(string scannerGUID)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError(scanResult.ErrorInfo);
|
||||
}
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
// 扫描器编辑相关
|
||||
public static AssetArtScanner CreateScanner(string name, string desc)
|
||||
{
|
||||
AssetArtScanner scanner = new AssetArtScanner();
|
||||
scanner.ScannerGUID = System.Guid.NewGuid().ToString();
|
||||
scanner.ScannerName = name;
|
||||
scanner.ScannerDesc = desc;
|
||||
Setting.Scanners.Add(scanner);
|
||||
IsDirty = true;
|
||||
return scanner;
|
||||
}
|
||||
public static void RemoveScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (Setting.Scanners.Remove(scanner))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove scanner : {scanner.ScannerName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (scanner != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集编辑相关
|
||||
public static void CreateCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
scanner.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/AssetArtScannerSettingData.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtScannerSettingData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fda10f23f6f36bf498b54323fe4f680b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
544
Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
544
Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
@ -0,0 +1,544 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetArt Scanner", false, 301)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetArtScannerWindow window = GetWindow<AssetArtScannerWindow>("AssetArt Scanner", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private Button _saveButton;
|
||||
private ListView _scannerListView;
|
||||
private ToolbarSearchField _scannerSearchField;
|
||||
private VisualElement _scannerContentContainer;
|
||||
private VisualElement _inspectorContainer;
|
||||
private Label _schemaGuideTxt;
|
||||
private TextField _scannerNameTxt;
|
||||
private TextField _scannerDescTxt;
|
||||
private ObjectField _scannerSchemaField;
|
||||
private ObjectField _outputFolderField;
|
||||
private ScrollView _collectorScrollView;
|
||||
|
||||
private int _lastModifyScannerIndex = 0;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
Undo.undoRedoPerformed -= RefreshWindow;
|
||||
Undo.undoRedoPerformed += RefreshWindow;
|
||||
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtScannerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_clicked;
|
||||
|
||||
// 配置保存按钮
|
||||
_saveButton = root.Q<Button>("SaveButton");
|
||||
_saveButton.clicked += SaveBtn_clicked;
|
||||
|
||||
// 扫描按钮
|
||||
var scanAllBtn = root.Q<Button>("ScanAllButton");
|
||||
scanAllBtn.clicked += ScanAllBtn_clicked;
|
||||
var scanBtn = root.Q<Button>("ScanBtn");
|
||||
scanBtn.clicked += ScanBtn_clicked;
|
||||
|
||||
// 扫描列表相关
|
||||
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||
_scannerListView.bindItem = BindScannerListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
||||
#else
|
||||
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 扫描列表过滤
|
||||
_scannerSearchField = root.Q<ToolbarSearchField>("ScannerSearchField");
|
||||
_scannerSearchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 扫描器添加删除按钮
|
||||
var scannerAddContainer = root.Q("ScannerAddContainer");
|
||||
{
|
||||
var addBtn = scannerAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddScannerBtn_clicked;
|
||||
var removeBtn = scannerAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveScannerBtn_clicked;
|
||||
}
|
||||
|
||||
// 扫描器容器
|
||||
_scannerContentContainer = root.Q("ScannerContentContainer");
|
||||
|
||||
// 检视界面容器
|
||||
_inspectorContainer = root.Q("InspectorContainer");
|
||||
|
||||
// 扫描器指南
|
||||
_schemaGuideTxt = root.Q<Label>("SchemaUserGuide");
|
||||
|
||||
// 扫描器名称
|
||||
_scannerNameTxt = root.Q<TextField>("ScannerName");
|
||||
_scannerNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerName = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描器备注
|
||||
_scannerDescTxt = root.Q<TextField>("ScannerDesc");
|
||||
_scannerDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerDesc = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描模式
|
||||
_scannerSchemaField = root.Q<ObjectField>("ScanSchema");
|
||||
_scannerSchemaField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
});
|
||||
|
||||
// 存储目录
|
||||
_outputFolderField = root.Q<ObjectField>("OutputFolder");
|
||||
_outputFolderField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
if (evt.newValue == null)
|
||||
{
|
||||
selectScanner.SaveDirectory = string.Empty;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
{
|
||||
selectScanner.SaveDirectory = assetPath;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Select asset object not folder ! {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 收集列表相关
|
||||
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||
_collectorScrollView.viewDataKey = "scrollView";
|
||||
|
||||
// 收集器创建按钮
|
||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||
{
|
||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddCollectorBtn_clicked;
|
||||
}
|
||||
|
||||
// 刷新窗体
|
||||
RefreshWindow();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 注意:清空所有撤销操作
|
||||
Undo.ClearAll();
|
||||
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (_saveButton != null)
|
||||
{
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
{
|
||||
if (_saveButton.enabledSelf == false)
|
||||
_saveButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_saveButton.enabledSelf)
|
||||
_saveButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ExportJsonConfig($"{resultPath}/AssetArtScannerConfig.json");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFilePath("Import JSON", "Assets/", "json");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ImportJsonConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
private void ScanAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始全面扫描!", "Yes", "No"))
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
AssetArtScannerSettingData.ScanAll(searchKeyWord);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("全面扫描已经取消");
|
||||
}
|
||||
}
|
||||
private void ScanBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
ScannerResult scannerResult = AssetArtScannerSettingData.Scan(selectScanner.ScannerGUID);
|
||||
if (scannerResult.Succeed)
|
||||
{
|
||||
// 自动打开报告界面
|
||||
scannerResult.OpenReportWindow();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_lastModifyScannerIndex = 0;
|
||||
RefreshWindow();
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillScannerListViewData()
|
||||
{
|
||||
_scannerListView.Clear();
|
||||
_scannerListView.ClearSelection();
|
||||
|
||||
var filterItems = FilterScanners();
|
||||
if (AssetArtScannerSettingData.Setting.Scanners.Count == filterItems.Count)
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = true;
|
||||
#endif
|
||||
_scannerListView.itemsSource = AssetArtScannerSettingData.Setting.Scanners;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = false;
|
||||
#endif
|
||||
_scannerListView.itemsSource = filterItems;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
}
|
||||
private List<AssetArtScanner> FilterScanners()
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
List<AssetArtScanner> result = new List<AssetArtScanner>(AssetArtScannerSettingData.Setting.Scanners.Count);
|
||||
|
||||
// 过滤列表
|
||||
foreach (var scanner in AssetArtScannerSettingData.Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(scanner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private VisualElement MakeScannerListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.height = 20f;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindScannerListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<AssetArtScanner> sourceList = _scannerListView.itemsSource as List<AssetArtScanner>;
|
||||
var scanner = sourceList[index];
|
||||
var textField1 = element.Q<Label>("Label1");
|
||||
if (string.IsNullOrEmpty(scanner.ScannerDesc))
|
||||
textField1.text = scanner.ScannerName;
|
||||
else
|
||||
textField1.text = $"{scanner.ScannerName} ({scanner.ScannerDesc})";
|
||||
}
|
||||
private void ScannerListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_scannerContentContainer.visible = true;
|
||||
_lastModifyScannerIndex = _scannerListView.selectedIndex;
|
||||
_scannerNameTxt.SetValueWithoutNotify(selectScanner.ScannerName);
|
||||
_scannerDescTxt.SetValueWithoutNotify(selectScanner.ScannerDesc);
|
||||
|
||||
// 显示检视面板
|
||||
var scanSchema = selectScanner.LoadSchema();
|
||||
RefreshInspector(scanSchema);
|
||||
|
||||
// 设置Schema对象
|
||||
if (scanSchema == null)
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(null);
|
||||
_schemaGuideTxt.text = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(scanSchema);
|
||||
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
||||
}
|
||||
|
||||
// 显示存储目录
|
||||
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
||||
if (saveFolder == null)
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(saveFolder);
|
||||
}
|
||||
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void AddScannerBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddScanner");
|
||||
AssetArtScannerSettingData.CreateScanner("Default Scanner", string.Empty);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void RemoveScannerBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveScanner");
|
||||
AssetArtScannerSettingData.RemoveScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectScanner.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
_collectorScrollView.Add(element);
|
||||
}
|
||||
}
|
||||
private VisualElement MakeCollectorListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
VisualElement elementTop = new VisualElement();
|
||||
elementTop.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementTop);
|
||||
|
||||
VisualElement elementSpace = new VisualElement();
|
||||
elementSpace.style.flexDirection = FlexDirection.Column;
|
||||
element.Add(elementSpace);
|
||||
|
||||
// Top VisualElement
|
||||
{
|
||||
var button = new Button();
|
||||
button.name = "Button1";
|
||||
button.text = "-";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.style.flexGrow = 0f;
|
||||
elementTop.Add(button);
|
||||
}
|
||||
{
|
||||
var objectField = new ObjectField();
|
||||
objectField.name = "ObjectField1";
|
||||
objectField.label = "Collector";
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
objectField.style.flexGrow = 1f;
|
||||
elementTop.Add(objectField);
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
|
||||
// Space VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.height = 10;
|
||||
elementSpace.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
var collector = selectScanner.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
removeBtn.clicked += () =>
|
||||
{
|
||||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Collector Path
|
||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||
objectField1.SetValueWithoutNotify(collectObject);
|
||||
objectField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetArtScannerSettingData.ModifyCollector(selectScanner, collector);
|
||||
});
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddCollector");
|
||||
AssetArtCollector collector = new AssetArtCollector();
|
||||
AssetArtScannerSettingData.CreateCollector(selectSacnner, collector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetArtCollector selectCollector)
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveCollector");
|
||||
AssetArtScannerSettingData.RemoveCollector(selectSacnner, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
// 属性面板相关
|
||||
private void RefreshInspector(ScannerSchema scanSchema)
|
||||
{
|
||||
if (scanSchema == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var inspector = scanSchema.CreateInspector();
|
||||
if (inspector == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspector.Containner is VisualElement container)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||
_inspectorContainer.Clear();
|
||||
_inspectorContainer.Add(container);
|
||||
_inspectorContainer.style.width = inspector.Width;
|
||||
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
11
Editor/AssetArtScanner/AssetArtScannerWindow.cs.meta
Normal file
11
Editor/AssetArtScanner/AssetArtScannerWindow.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bff583b32bbeb7e498920bfdc84dba90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Editor/AssetArtScanner/AssetArtScannerWindow.uxml
Normal file
33
Editor/AssetArtScanner/AssetArtScannerWindow.uxml
Normal file
@ -0,0 +1,33 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Scan All" display-tooltip-when-elided="true" name="ScanAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="ScannerListContainer" style="width: 250px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Scanner List" display-tooltip-when-elided="true" name="ScannerListTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; font-size: 12px;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="ScannerSearchField" style="width: 230px;" />
|
||||
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" reorder-mode="Animated" reorderable="true" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="ScannerAddContainer" style="justify-content: center; flex-direction: row; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ScannerContentContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; min-width: 400px;">
|
||||
<ui:Label text="Scanner" display-tooltip-when-elided="true" name="ScannerContentTitle" style="-unity-text-align: upper-center; -unity-font-style: bold; font-size: 12px; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; background-color: rgb(89, 89, 89);" />
|
||||
<ui:Label display-tooltip-when-elided="true" name="SchemaUserGuide" style="-unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px; height: 40px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Name" name="ScannerName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
||||
<uie:ObjectField label="Scanner Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" allow-scene-objects="false" />
|
||||
<uie:ObjectField label="Output Folder" name="OutputFolder" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
<ui:Button text="Scan" display-tooltip-when-elided="true" name="ScanBtn" style="width: 60px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="InspectorContainer" style="flex-grow: 1; border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px; background-color: rgb(67, 67, 67);" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
10
Editor/AssetArtScanner/AssetArtScannerWindow.uxml.meta
Normal file
10
Editor/AssetArtScanner/AssetArtScannerWindow.uxml.meta
Normal file
@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bbb873a7bee2924a86c876b67bb2cb4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
26
Editor/AssetArtScanner/ScannerDefine.cs
Normal file
26
Editor/AssetArtScanner/ScannerDefine.cs
Normal file
@ -0,0 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 报告文件签名
|
||||
/// </summary>
|
||||
public const string ReportFileSign = "596f6f4172745265706f7274";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件签名
|
||||
/// </summary>
|
||||
public const string SettingFileSign = "596f6f41727453657474696e67";
|
||||
|
||||
/// <summary>
|
||||
/// 报告文件的版本
|
||||
/// </summary>
|
||||
public const string ReportFileVersion = "1.0";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件的版本
|
||||
/// </summary>
|
||||
public const string SettingFileVersion = "1.0";
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
11
Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed658bfc32cbfc44caf262a741a7c387
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
59
Editor/AssetArtScanner/ScannerResult.cs
Normal file
59
Editor/AssetArtScanner/ScannerResult.cs
Normal file
@ -0,0 +1,59 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成的报告文件路径
|
||||
/// </summary>
|
||||
public string ReprotFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告对象
|
||||
/// </summary>
|
||||
public ScanReport Report { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool Succeed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(ErrorInfo))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ScannerResult(string error)
|
||||
{
|
||||
ErrorInfo = error;
|
||||
}
|
||||
public ScannerResult(string filePath, ScanReport report)
|
||||
{
|
||||
ReprotFilePath = filePath;
|
||||
Report = report;
|
||||
ErrorInfo = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开报告窗口
|
||||
/// </summary>
|
||||
public void OpenReportWindow()
|
||||
{
|
||||
if (Succeed)
|
||||
{
|
||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||
reproterWindow.ImportSingleReprotFile(ReprotFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
11
Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e10cdab189d80b142ad5903d12956c59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Editor/AssetArtScanner/ScannerSchema.cs
Normal file
32
Editor/AssetArtScanner/ScannerSchema.cs
Normal file
@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public abstract class ScannerSchema : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户指南信息
|
||||
/// </summary>
|
||||
public abstract string GetUserGuide();
|
||||
|
||||
/// <summary>
|
||||
/// 运行生成扫描报告
|
||||
/// </summary>
|
||||
public abstract ScanReport RunScanner(AssetArtScanner scanner);
|
||||
|
||||
/// <summary>
|
||||
/// 修复扫描结果
|
||||
/// </summary>
|
||||
public abstract void FixResult(List<ReportElement> fixList);
|
||||
|
||||
/// <summary>
|
||||
/// 创建检视面板
|
||||
/// </summary>
|
||||
public virtual SchemaInspector CreateInspector()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
11
Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb6a587c72ccecc4ab6d386063cf0736
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
45
Editor/AssetArtScanner/SchemaInspector.cs
Normal file
45
Editor/AssetArtScanner/SchemaInspector.cs
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class SchemaInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// 检视界面的UI元素容器(UIElements元素)
|
||||
/// </summary>
|
||||
public object Containner { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面宽度
|
||||
/// </summary>
|
||||
public int Width = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最小宽度
|
||||
/// </summary>
|
||||
public int MinWidth = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = 250;
|
||||
|
||||
public SchemaInspector(object containner)
|
||||
{
|
||||
Containner = containner;
|
||||
}
|
||||
public SchemaInspector(object containner, int width)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public SchemaInspector(object containner, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
}
|
11
Editor/AssetArtScanner/SchemaInspector.cs.meta
Normal file
11
Editor/AssetArtScanner/SchemaInspector.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3440549fcb36bbf4c8c6da17fb858947
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -36,7 +36,7 @@ namespace YooAsset.Editor
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
|
||||
// 执行构建流程
|
||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
}
|
||||
}
|
||||
}
|
@ -56,13 +56,13 @@ namespace YooAsset.Editor
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
private readonly Dictionary<string, BuildAssetInfo> _packAssetDic = new Dictionary<string, BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
public readonly List<BuildAssetInfo> AllPackAssets = new List<BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
public bool IsContainsPackAsset(string assetPath)
|
||||
{
|
||||
return _assetPaths.Contains(assetPath);
|
||||
return _packAssetDic.ContainsKey(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetAllMainAssetPaths()
|
||||
public string[] GetAllPackAssetPaths()
|
||||
{
|
||||
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||
/// 获取构建的主资源信息
|
||||
/// </summary>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
public BuildAssetInfo GetPackAssetInfo(string assetPath)
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(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}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包内部所有资产
|
||||
/// </summary>
|
||||
public List<AssetInfo> GetBundleContents()
|
||||
{
|
||||
Dictionary<string, AssetInfo> result = new Dictionary<string, AssetInfo>(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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
||||
/// 未被依赖的资源列表
|
||||
/// </summary>
|
||||
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
@ -96,14 +96,14 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建着色器信息类
|
||||
/// 创建空的资源包
|
||||
/// </summary>
|
||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||
public void CreateEmptyBundleInfo(string bundleName)
|
||||
{
|
||||
if (IsContainsBundle(shadersBundleName) == false)
|
||||
if (IsContainsBundle(bundleName) == false)
|
||||
{
|
||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||
var bundleInfo = new BuildBundleInfo(bundleName);
|
||||
_bundleInfoDic.Add(bundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ namespace YooAsset.Editor
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖缓存数据库
|
||||
/// 说明:开启此项可以极大提高资源收集速度
|
||||
/// 说明:开启此项可以极大提高资源收集速度!
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB = false;
|
||||
|
||||
@ -67,6 +67,12 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableSharePackRule = false;
|
||||
|
||||
/// <summary>
|
||||
/// 对单独引用的共享资源进行独立打包
|
||||
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||
/// </summary>
|
||||
public bool SingleReferencedPackAlone = true;
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
|
@ -43,17 +43,21 @@ namespace YooAsset.Editor
|
||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||
|
||||
// 处理资源清单的ID数据
|
||||
ProcessPacakgeIDs(manifest);
|
||||
// 1. 处理资源清单的资源对象
|
||||
ProcessPacakgeAsset(manifest);
|
||||
|
||||
// 处理资源包的依赖列表
|
||||
// 2. 处理资源包的依赖列表
|
||||
if (processBundleDepends)
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
// 3. 处理资源包的标签集合
|
||||
if (processBundleTags)
|
||||
ProcessBundleTags(manifest);
|
||||
|
||||
// 4. 处理内置资源包
|
||||
if (processBundleDepends)
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
@ -64,17 +68,13 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
string packageHash;
|
||||
string packagePath;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(packagePath);
|
||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
@ -92,6 +92,14 @@ namespace YooAsset.Editor
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
|
||||
// 填充上下文
|
||||
{
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -137,7 +145,7 @@ namespace YooAsset.Editor
|
||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
||||
packageAsset.TempDataInEditor = assetInfo;
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
@ -165,9 +173,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源清单的ID数据
|
||||
/// 处理资源清单的资源对象列表
|
||||
/// </summary>
|
||||
private void ProcessPacakgeIDs(PackageManifest manifest)
|
||||
private void ProcessPacakgeAsset(PackageManifest manifest)
|
||||
{
|
||||
// 注意:优先缓存资源包索引
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
@ -176,10 +184,19 @@ namespace YooAsset.Editor
|
||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||
}
|
||||
|
||||
// 记录资源对象所属的资源包ID
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
string bundleName = packageAsset.BundleNameInEditor;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
|
||||
}
|
||||
|
||||
// 记录资源对象依赖的资源包ID集合
|
||||
// 注意:依赖关系非引擎构建结果里查询!
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,15 +209,18 @@ namespace YooAsset.Editor
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(depends.Length);
|
||||
foreach (var dependBundleName in depends)
|
||||
string[] dependNames = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(dependNames.Length);
|
||||
foreach (var dependName in dependNames)
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
int dependBundleID = GetCachedBundleIndexID(dependName);
|
||||
if (dependBundleID != mainBundleID)
|
||||
dependIDs.Add(dependBundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
|
||||
// 排序并填充数据
|
||||
dependIDs.Sort();
|
||||
packageBundle.DependBundleIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,23 +229,27 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
packageBundle.Tags = Array.Empty<string>();
|
||||
}
|
||||
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
if (packageBundle.DependIDs != null)
|
||||
if (packageAsset.DependBundleIDs != null)
|
||||
{
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
foreach (var dependBundleID in packageAsset.DependBundleIDs)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将缓存的资源标签赋值给资源包
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
@ -264,5 +288,94 @@ namespace YooAsset.Editor
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含该资源包的索引ID
|
||||
/// </summary>
|
||||
private bool ContainsCachedBundleIndexID(string bundleName)
|
||||
{
|
||||
return _cachedBundleIndexIDs.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
#region YOOASSET_LEGACY_DEPENDENCY
|
||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||
// 注意:该步骤依赖前面的操作!
|
||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
if (buildResultContext != null)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
ManifestTools.InitManifest(manifest);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
|
||||
}
|
||||
}
|
||||
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(builtinBundleName))
|
||||
return;
|
||||
|
||||
// 查询内置资源包是否存在
|
||||
if (ContainsCachedBundleIndexID(builtinBundleName) == false)
|
||||
return;
|
||||
|
||||
// 获取内置资源包
|
||||
int builtinBundleID = GetCachedBundleIndexID(builtinBundleName);
|
||||
var builtinPackageBundle = manifest.BundleList[builtinBundleID];
|
||||
|
||||
// 更新依赖资源包ID集合
|
||||
HashSet<int> cacheBundleIDs = new HashSet<int>(builtinPackageBundle.ReferenceBundleIDs);
|
||||
HashSet<string> tempTags = new HashSet<string>();
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
if (cacheBundleIDs.Contains(packageAsset.BundleID))
|
||||
{
|
||||
if (packageAsset.DependBundleIDs.Contains(builtinBundleID) == false)
|
||||
{
|
||||
var tempBundleIDs = new List<int>(packageAsset.DependBundleIDs);
|
||||
tempBundleIDs.Add(builtinBundleID);
|
||||
packageAsset.DependBundleIDs = tempBundleIDs.ToArray();
|
||||
}
|
||||
|
||||
foreach (var tag in packageAsset.AssetTags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新内置资源包的标签集合
|
||||
foreach (var tag in builtinPackageBundle.Tags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
builtinPackageBundle.Tags = tempTags.ToArray();
|
||||
}
|
||||
private int[] GetAssetDependBundleIDs(BuildAssetInfo mainAssetInfo)
|
||||
{
|
||||
HashSet<int> result = new HashSet<int>();
|
||||
int mainBundleID = GetCachedBundleIndexID(mainAssetInfo.BundleName);
|
||||
foreach (var dependAssetInfo in mainAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
if (dependAssetInfo.HasBundleName())
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependAssetInfo.BundleName);
|
||||
if (mainBundleID != bundleID)
|
||||
{
|
||||
if (result.Contains(bundleID) == false)
|
||||
result.Add(bundleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 排序并返回数据
|
||||
List<int> listResult = new List<int>(result);
|
||||
listResult.Sort();
|
||||
return listResult.ToArray();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -18,11 +18,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.YooVersion = EditorTools.GetPackageManagerYooVersion();
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
@ -38,36 +34,34 @@ 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.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;
|
||||
}
|
||||
|
||||
// 构建结果
|
||||
@ -91,7 +85,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);
|
||||
}
|
||||
|
||||
@ -107,8 +102,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);
|
||||
}
|
||||
|
||||
@ -123,12 +119,28 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
private List<AssetInfo> GetAssetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
List<AssetInfo> result = new List<AssetInfo>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
var assetInfo = bundleInfo.GetPackAssetInfo(assetPath);
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetInfo);
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetAssetDependBundles(PackageManifest manifest, PackageAsset packageAsset)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageAsset.DependBundleIDs.Length);
|
||||
foreach (int index in packageAsset.DependBundleIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
@ -138,42 +150,42 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// 获取资源包依赖的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
private List<string> GetBundleDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependBundleIDs.Length);
|
||||
foreach (int index in packageBundle.DependBundleIDs)
|
||||
{
|
||||
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;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
dependBundles.Sort();
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源
|
||||
/// 获取引用该资源包的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
private List<string> GetBundleReferenceBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> referenceBundles = new List<string>(packageBundle.ReferenceBundleIDs.Count);
|
||||
foreach (int index in packageBundle.ReferenceBundleIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
referenceBundles.Add(dependBundleName);
|
||||
}
|
||||
referenceBundles.Sort();
|
||||
return referenceBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包内部所有资产
|
||||
/// </summary>
|
||||
private List<AssetInfo> GetBundleContents(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||
List<AssetInfo> result = bundleInfo.GetBundleContents();
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 1. 获取所有收集器收集的资源
|
||||
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, useAssetDependencyDB, packageName);
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.BeginCollect(packageName, simulateBuild, useAssetDependencyDB);
|
||||
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
@ -109,15 +109,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||
if (packRuleResult.IsValid())
|
||||
{
|
||||
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
buildAssetInfo.SetBundleName(shareBundleName);
|
||||
}
|
||||
ProcessingPackShareBundle(buildParameters, collectResult.Command, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
PostProcessPackShareBundle();
|
||||
PostProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||
}
|
||||
|
||||
// 8. 记录关键信息
|
||||
@ -209,21 +204,38 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 共享资源打包后置处理
|
||||
/// 共享资源打包机制
|
||||
/// </summary>
|
||||
protected virtual void PostProcessPackShareBundle()
|
||||
protected virtual void ProcessingPackShareBundle(BuildParameters buildParameters, CollectCommand command, BuildAssetInfo buildAssetInfo)
|
||||
{
|
||||
}
|
||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||
if (packRuleResult.IsValid() == false)
|
||||
return;
|
||||
|
||||
/// <summary>
|
||||
/// 获取共享资源包名称
|
||||
/// </summary>
|
||||
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||
// 处理单个引用的共享资源
|
||||
if (buildAssetInfo.GetReferenceBundleCount() <= 1)
|
||||
{
|
||||
if (buildParameters.SingleReferencedPackAlone == false)
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置共享资源包名
|
||||
string shareBundleName = packRuleResult.GetShareBundleName(command.PackageName, command.UniqueBundleName);
|
||||
buildAssetInfo.SetBundleName(shareBundleName);
|
||||
}
|
||||
private PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 共享资源打包后置处理
|
||||
/// </summary>
|
||||
protected virtual void PostProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -13,6 +13,8 @@ namespace YooAsset.Editor
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
public string BuiltinShadersBundleName;
|
||||
public string MonoScriptsBundleName;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@ -27,7 +29,9 @@ namespace YooAsset.Editor
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName, null);
|
||||
string builtinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
|
||||
string monoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
|
||||
var taskList = SBPBuildTasks.Create(builtinShadersBundleName, monoScriptsBundleName);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
@ -35,18 +39,24 @@ namespace YooAsset.Editor
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 创建着色器信息
|
||||
// 说明:解决因为着色器资源包导致验证失败。
|
||||
// 说明:解决因为特殊资源包导致验证失败。
|
||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||
if (string.IsNullOrEmpty(builtinShadersBundleName) == false)
|
||||
{
|
||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||
if (buildResults.BundleInfos.ContainsKey(builtinShadersBundleName))
|
||||
buildMapContext.CreateEmptyBundleInfo(builtinShadersBundleName);
|
||||
}
|
||||
if (string.IsNullOrEmpty(monoScriptsBundleName) == false)
|
||||
{
|
||||
if (buildResults.BundleInfos.ContainsKey(monoScriptsBundleName))
|
||||
buildMapContext.CreateEmptyBundleInfo(monoScriptsBundleName);
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
buildResultContext.BuiltinShadersBundleName = builtinShadersBundleName;
|
||||
buildResultContext.MonoScriptsBundleName = monoScriptsBundleName;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
{
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName, string unityMonoScriptsBundleName)
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName, string monoScriptsBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
@ -30,8 +30,8 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
if (string.IsNullOrEmpty(unityMonoScriptsBundleName) == false)
|
||||
buildTasks.Add(new CreateMonoScriptBundle(unityMonoScriptsBundleName));
|
||||
if (string.IsNullOrEmpty(monoScriptsBundleName) == false)
|
||||
buildTasks.Add(new CreateMonoScriptBundle(monoScriptsBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
|
||||
// Packing
|
||||
|
@ -41,6 +41,17 @@ namespace YooAsset.Editor
|
||||
public int CacheServerPort;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// </summary>
|
||||
public string BuiltinShadersBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// Mono脚本资源包名称
|
||||
/// </summary>
|
||||
public string MonoScriptsBundleName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取可编程构建管线的构建参数
|
||||
/// </summary>
|
||||
|
@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// 清空所有上下文对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// 设置上下文对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
@ -46,5 +46,21 @@ namespace YooAsset.Editor
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T TryGetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ namespace YooAsset.Editor
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
@ -45,6 +46,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
@ -52,6 +54,17 @@ namespace YooAsset.Editor
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
private string GetBuiltinShaderBundleName()
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -98,9 +98,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取打包收集的资源文件
|
||||
/// 获取收集的资源列表
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
||||
public List<CollectAssetInfo> GetCollectAssets(CollectCommand command)
|
||||
{
|
||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||
|
||||
@ -138,7 +138,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
// 返回列表
|
||||
// 返回结果
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
|
@ -86,10 +86,16 @@ namespace YooAsset.Editor
|
||||
return package.GetAllTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取包裹收集的资源文件
|
||||
/// </summary>
|
||||
[Obsolete("This method will be removed in a future ! Use BeginCollect instead.", true)]
|
||||
public CollectResult GetPackageAssets(bool simulateBuild, bool useAssetDependencyDB, string packageName)
|
||||
{
|
||||
return BeginCollect(packageName, simulateBuild, useAssetDependencyDB);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 收集指定包裹的资源文件
|
||||
/// </summary>
|
||||
public CollectResult BeginCollect(string packageName, bool simulateBuild, bool useAssetDependencyDB)
|
||||
{
|
||||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Build package name is null or empty !");
|
||||
@ -100,16 +106,18 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建资源收集命令
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||
CollectCommand command = new CollectCommand(simulateBuild, useAssetDependencyDB, packageName,
|
||||
package.EnableAddressable,
|
||||
package.LocationToLower,
|
||||
package.IncludeAssetGUID,
|
||||
package.AutoCollectShaders,
|
||||
UniqueBundleName, ignoreRule);
|
||||
var command = new CollectCommand(packageName, ignoreRule);
|
||||
command.SimulateBuild = simulateBuild;
|
||||
command.UniqueBundleName = UniqueBundleName;
|
||||
command.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
command.EnableAddressable = package.EnableAddressable;
|
||||
command.LocationToLower = package.LocationToLower;
|
||||
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
||||
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||
|
||||
// 获取收集的资源集合
|
||||
CollectResult collectResult = new CollectResult(command);
|
||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
||||
// 开始收集工作
|
||||
var collectAssets = package.GetCollectAssets(command);
|
||||
var collectResult = new CollectResult(command, collectAssets);
|
||||
return collectResult;
|
||||
}
|
||||
|
||||
|
@ -164,25 +164,25 @@ namespace YooAsset.Editor
|
||||
RefreshWindow();
|
||||
}
|
||||
});
|
||||
|
||||
// 忽略规则
|
||||
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
|
||||
_ignoreRulePopupField.label = "File Ignore Rule";
|
||||
_ignoreRulePopupField.name = "IgnoreRulePopupField";
|
||||
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
_ignoreRulePopupField.style.width = 300;
|
||||
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
|
||||
_ignoreRulePopupField.label = "File Ignore Rule";
|
||||
_ignoreRulePopupField.name = "IgnoreRulePopupField";
|
||||
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
_ignoreRulePopupField.style.width = 300;
|
||||
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
if (selectPackage != null)
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
if (selectPackage != null)
|
||||
{
|
||||
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||
}
|
||||
});
|
||||
_setting2Container.Add(_ignoreRulePopupField);
|
||||
}
|
||||
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||
}
|
||||
});
|
||||
_setting2Container.Add(_ignoreRulePopupField);
|
||||
|
||||
// 配置修复按钮
|
||||
var fixBtn = root.Q<Button>("FixButton");
|
||||
@ -995,14 +995,16 @@ namespace YooAsset.Editor
|
||||
try
|
||||
{
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
CollectCommand command = new CollectCommand(true, false,
|
||||
_packageNameTxt.value,
|
||||
_enableAddressableToogle.value,
|
||||
_locationToLowerToogle.value,
|
||||
_includeAssetGUIDToogle.value,
|
||||
_autoCollectShadersToogle.value,
|
||||
_uniqueBundleNameToogle.value,
|
||||
ignoreRule);
|
||||
string packageName = _packageNameTxt.value;
|
||||
var command = new CollectCommand(packageName, ignoreRule);
|
||||
command.SimulateBuild = true;
|
||||
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||
command.UseAssetDependencyDB = true;
|
||||
command.EnableAddressable = _enableAddressableToogle.value;
|
||||
command.LocationToLower = _locationToLowerToogle.value;
|
||||
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
||||
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
||||
|
||||
collector.CheckConfigError();
|
||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||
}
|
||||
|
@ -28,7 +28,7 @@
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
@ -36,9 +36,9 @@
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="GroupContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Groups" display-tooltip-when-elided="true" name="GroupTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Name" value="filler text" name="PackageName" style="flex-direction: column;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Desc" value="filler text" name="PackageDesc" style="flex-direction: column;" />
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
|
@ -40,13 +40,15 @@ namespace YooAsset.Editor
|
||||
_databaseFilePath = databaseFilePath;
|
||||
_database.Clear();
|
||||
|
||||
FileStream stream = null;
|
||||
BinaryReader reader = null;
|
||||
try
|
||||
{
|
||||
if (readCacheDatabaseFile && File.Exists(databaseFilePath))
|
||||
{
|
||||
// 解析缓存文件
|
||||
using var stream = File.OpenRead(databaseFilePath);
|
||||
using var reader = new BinaryReader(stream);
|
||||
stream = File.OpenRead(databaseFilePath);
|
||||
reader = new BinaryReader(stream);
|
||||
string fileVersion = reader.ReadString();
|
||||
if (fileVersion != FILE_VERSION)
|
||||
throw new Exception("The database file version not match !");
|
||||
@ -85,6 +87,13 @@ namespace YooAsset.Editor
|
||||
ClearDatabase(true);
|
||||
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader != null)
|
||||
reader.Close();
|
||||
if (stream != null)
|
||||
stream.Close();
|
||||
}
|
||||
|
||||
// 查找新增或变动资源
|
||||
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
||||
@ -114,10 +123,12 @@ namespace YooAsset.Editor
|
||||
if (File.Exists(_databaseFilePath))
|
||||
File.Delete(_databaseFilePath);
|
||||
|
||||
FileStream stream = null;
|
||||
BinaryWriter writer = null;
|
||||
try
|
||||
{
|
||||
using var stream = File.Create(_databaseFilePath);
|
||||
using var writer = new BinaryWriter(stream);
|
||||
stream = File.Create(_databaseFilePath);
|
||||
writer = new BinaryWriter(stream);
|
||||
writer.Write(FILE_VERSION);
|
||||
writer.Write(_database.Count);
|
||||
foreach (var assetPair in _database)
|
||||
@ -134,6 +145,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
Debug.LogError($"Failed to save cache database : {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (writer != null)
|
||||
writer.Close();
|
||||
if (stream != null)
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -3,75 +3,51 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
public bool SimulateBuild { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖数据库
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 着色器统一全名称
|
||||
/// </summary>
|
||||
public string ShadersBundleName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 忽略规则实例
|
||||
/// </summary>
|
||||
public IIgnoreRule IgnoreRule { private set; get; }
|
||||
|
||||
|
||||
public CollectCommand(bool simulateBuild, bool useAssetDependencyDB, string packageName,
|
||||
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
||||
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
|
||||
{
|
||||
SimulateBuild = simulateBuild;
|
||||
UseAssetDependencyDB = useAssetDependencyDB;
|
||||
PackageName = packageName;
|
||||
EnableAddressable = enableAddressable;
|
||||
LocationToLower = locationToLower;
|
||||
IncludeAssetGUID = includeAssetGUID;
|
||||
AutoCollectShaders = autoCollectShaders;
|
||||
UniqueBundleName = uniqueBundleName;
|
||||
IgnoreRule = ignoreRule;
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
public bool SimulateBuild { set; get; }
|
||||
|
||||
// 着色器统一全名称
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||
}
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
/// </summary>
|
||||
public bool UniqueBundleName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖数据库
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 启用可寻址资源定位
|
||||
/// </summary>
|
||||
public bool EnableAddressable { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
public bool LocationToLower { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 包含资源GUID数据
|
||||
/// </summary>
|
||||
public bool IncludeAssetGUID { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动收集所有着色器
|
||||
/// </summary>
|
||||
public bool AutoCollectShaders { set; get; }
|
||||
|
||||
private AssetDependencyCache _assetDependency;
|
||||
public AssetDependencyCache AssetDependency
|
||||
@ -83,5 +59,11 @@ namespace YooAsset.Editor
|
||||
return _assetDependency;
|
||||
}
|
||||
}
|
||||
|
||||
public CollectCommand(string packageName, IIgnoreRule ignoreRule)
|
||||
{
|
||||
PackageName = packageName;
|
||||
IgnoreRule = ignoreRule;
|
||||
}
|
||||
}
|
||||
}
|
@ -15,12 +15,9 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||
|
||||
public CollectResult(CollectCommand command)
|
||||
public CollectResult(CollectCommand command, List<CollectAssetInfo> collectAssets)
|
||||
{
|
||||
Command = command;
|
||||
}
|
||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
||||
{
|
||||
CollectAssets = collectAssets;
|
||||
}
|
||||
}
|
||||
|
@ -240,8 +240,8 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
||||
_assetListViewer.FillViewData(debugReport);
|
||||
_bundleListViewer.FillViewData(debugReport);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,7 +272,7 @@ namespace YooAsset.Editor
|
||||
packageData.ProviderInfos.Sort();
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
providerInfo.DependBundleInfos.Sort();
|
||||
providerInfo.DependBundles.Sort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,8 +286,8 @@ namespace YooAsset.Editor
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_currentReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
||||
_assetListViewer.RebuildView(_searchKeyWord);
|
||||
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||
|
@ -11,12 +11,25 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerAssetListViewer
|
||||
{
|
||||
private class ProviderTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class DependTableData : DefaultTableData
|
||||
{
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private TableView _providerTableView;
|
||||
private TableView _dependTableView;
|
||||
|
||||
private DebugReport _debugReport;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@ -32,26 +45,288 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_assetListView.selectionChanged += AssetListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
_providerTableView = _root.Q<TableView>("TopTableView");
|
||||
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
|
||||
CreateAssetTableViewColumns();
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
_dependTableView = _root.Q<TableView>("BottomTableView");
|
||||
CreateDependTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
#endif
|
||||
}
|
||||
private void CreateAssetTableViewColumns()
|
||||
{
|
||||
// PackageName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(200);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("PackageName", "Package Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// AssetPath
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// SpawnScene
|
||||
{
|
||||
var columnStyle = new ColumnStyle(150);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("SpawnScene", "Spawn Scene", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// SpawnTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// LoadingTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("LoadingTime", "Loading Time", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var providerTableData = data as ProviderTableData;
|
||||
if (providerTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_providerTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateDependTableViewColumns()
|
||||
{
|
||||
//DependBundles
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var dependTableData = data as DependTableData;
|
||||
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
|
||||
// 清空旧数据
|
||||
_providerTableView.ClearAll(false, true);
|
||||
_dependTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
var rowData = new ProviderTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
|
||||
rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime);
|
||||
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", providerInfo.Status.ToString());
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
_providerTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
@ -59,45 +334,21 @@ namespace YooAsset.Editor
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource.Clear();
|
||||
_assetListView.Rebuild();
|
||||
_providerTableView.ClearAll(false, true);
|
||||
_dependTableView.ClearAll(false, true);
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
providerInfo.PackageName = packageData.PackageName;
|
||||
tempList.Add(providerInfo);
|
||||
}
|
||||
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
// 重建视图
|
||||
_providerTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -116,194 +367,26 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
private void OnProviderTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var providerTableData = data as ProviderTableData;
|
||||
DebugPackageData packageData = providerTableData.PackageData;
|
||||
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
||||
|
||||
// 填充依赖数据
|
||||
var sourceDatas = new List<ITableData>(providerInfo.DependBundles.Count);
|
||||
foreach (var bundleName in providerInfo.DependBundles)
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
var dependBundleInfo = packageData.GetBundleInfo(bundleName);
|
||||
var rowData = new DependTableData();
|
||||
rowData.BundleInfo = dependBundleInfo;
|
||||
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", dependBundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", dependBundleInfo.Status.ToString());
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
|
||||
{
|
||||
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 = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label6";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||
var providerInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = providerInfo.PackageName;
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Loading Time
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.LoadingTime.ToString();
|
||||
|
||||
// Ref Count
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label6 = element.Q<Label>("Label6");
|
||||
label6.text = providerInfo.Status.ToString();
|
||||
label6.style.color = textColor;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||
FillDependListView(providerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
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 = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||
DebugBundleInfo bundleInfo = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
}
|
||||
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||
{
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
_dependTableView.itemsSource = sourceDatas;
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Loading Time (ms)" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar5" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar6" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<YooAsset.Editor.TableView name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@ -11,12 +11,29 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerBundleListViewer
|
||||
{
|
||||
private class BundleTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
private class UsingTableData : DefaultTableData
|
||||
{
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class ReferenceTableData : DefaultTableData
|
||||
{
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _bundleListView;
|
||||
private ListView _usingListView;
|
||||
private TableView _bundleTableView;
|
||||
private TableView _usingTableView;
|
||||
private TableView _referenceTableView;
|
||||
|
||||
private DebugReport _debugReport;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@ -32,26 +49,343 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
_bundleTableView = _root.Q<TableView>("BundleTableView");
|
||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||
CreateBundleTableViewColumns();
|
||||
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
_usingListView.bindItem = BindIncludeListViewItem;
|
||||
_usingTableView = _root.Q<TableView>("UsingTableView");
|
||||
CreateUsingTableViewColumns();
|
||||
|
||||
// 引用列表
|
||||
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
|
||||
CreateReferenceTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
PanelSplitView.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
||||
#endif
|
||||
}
|
||||
private void CreateBundleTableViewColumns()
|
||||
{
|
||||
// PackageName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(200);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("PackageName", "Package Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var bundleTableData = data as BundleTableData;
|
||||
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateUsingTableViewColumns()
|
||||
{
|
||||
// UsingAssets
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("UsingAssets", "Using Assets", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// SpawnScene
|
||||
{
|
||||
var columnStyle = new ColumnStyle(150);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("SpawnScene", "Spawn Scene", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// SpawnTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var usingTableData = data as UsingTableData;
|
||||
if (usingTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateReferenceTableViewColumns()
|
||||
{
|
||||
// BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var feferenceTableData = data as ReferenceTableData;
|
||||
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
|
||||
// 清空旧数据
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
foreach (var bundleInfo in packageData.BundleInfos)
|
||||
{
|
||||
var rowData = new BundleTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
_bundleTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
@ -59,52 +393,24 @@ namespace YooAsset.Editor
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource.Clear();
|
||||
_bundleListView.Rebuild();
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_bundleTableView.RebuildView();
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_usingTableView.RebuildView();
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||
foreach (var pakcageData in debugReport.PackageDatas)
|
||||
{
|
||||
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||
{
|
||||
bundleInfo.PackageName = pakcageData.PackageName;
|
||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tempList = tempDic.Values.ToList();
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
// 重建视图
|
||||
_bundleTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -123,199 +429,53 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var bundleTableData = data as BundleTableData;
|
||||
var packageData = bundleTableData.PackageData;
|
||||
var selectBundleInfo = bundleTableData.BundleInfo;
|
||||
|
||||
// 填充UsingTableView
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
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 = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = bundleInfo.PackageName;
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == EOperationStatus.Failed)
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
label4.style.color = textColor;
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||
FillUsingListView(bundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
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 = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||
DebugProviderInfo providerInfo = providers[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var packageData in _debugReport.PackageDatas)
|
||||
{
|
||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
foreach (var dependBundleName in providerInfo.DependBundles)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
if (dependBundleName == selectBundleInfo.BundleName)
|
||||
{
|
||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||
{
|
||||
source.Add(providerInfo);
|
||||
continue;
|
||||
}
|
||||
var rowData = new UsingTableData();
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
|
||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
|
||||
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", providerInfo.Status);
|
||||
sourceDatas.Add(rowData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_usingTableView.itemsSource = sourceDatas;
|
||||
_usingTableView.RebuildView();
|
||||
}
|
||||
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
// 填充ReferenceTableView
|
||||
{
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
foreach (string referenceBundleName in selectBundleInfo.ReferenceBundles)
|
||||
{
|
||||
var bundleInfo = packageData.GetBundleInfo(referenceBundleName);
|
||||
var rowData = new ReferenceTableData();
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
_referenceTableView.itemsSource = sourceDatas;
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,9 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<YooAsset.Editor.TableView name="BundleTableView" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Using Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="BottomBar2" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="BottomBar3" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar4" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 400px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableView name="UsingTableView" />
|
||||
<YooAsset.Editor.TableView name="ReferenceTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@ -112,16 +112,16 @@ namespace YooAsset.Editor
|
||||
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
||||
_buildReport = BuildReport.Deserialize(jsonData);
|
||||
_summaryViewer.FillViewData(_buildReport);
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_assetListViewer.FillViewData(_buildReport, _reportFilePath);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
if (_buildReport != null)
|
||||
{
|
||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
||||
_assetListViewer.RebuildView(_searchKeyWord);
|
||||
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||
|
@ -39,8 +39,14 @@ namespace YooAsset.Editor
|
||||
public long MainBundleSize;
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源路径列表
|
||||
/// 依赖的资源集合
|
||||
/// </summary>
|
||||
public List<string> DependAssets = new List<string>();
|
||||
public List<AssetInfo> DependAssets = new List<AssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源包集合
|
||||
/// 说明:框架层收集查询结果
|
||||
/// </summary>
|
||||
public List<string> DependBundles = new List<string>();
|
||||
}
|
||||
}
|
@ -44,14 +44,21 @@ namespace YooAsset.Editor
|
||||
public string[] Tags;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包的依赖集合
|
||||
/// 依赖的资源包集合
|
||||
/// 说明:引擎层构建查询结果
|
||||
/// </summary>
|
||||
public List<string> DependBundles;
|
||||
public List<string> DependBundles = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 该资源包内包含的所有资源
|
||||
/// 引用该资源包的资源包集合
|
||||
/// 说明:谁依赖该资源包
|
||||
/// </summary>
|
||||
public List<string> AllBuiltinAssets = new List<string>();
|
||||
public List<string> ReferenceBundles = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包内部所有资产
|
||||
/// </summary>
|
||||
public List<AssetInfo> BundleContents = new List<AssetInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源分类标签的字符串
|
||||
|
@ -70,11 +70,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;
|
||||
|
@ -6,30 +6,30 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterAssetListViewer
|
||||
{
|
||||
private enum ESortMode
|
||||
private class AssetTableData : DefaultTableData
|
||||
{
|
||||
AssetPath,
|
||||
BundleName
|
||||
public ReportAssetInfo AssetInfo;
|
||||
}
|
||||
private class DependTableData : DefaultTableData
|
||||
{
|
||||
public ReportBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ToolbarButton _topBar1;
|
||||
private ToolbarButton _topBar2;
|
||||
private ToolbarButton _bottomBar1;
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private TableView _assetTableView;
|
||||
private TableView _dependTableView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _searchKeyWord;
|
||||
private ESortMode _sortMode = ESortMode.AssetPath;
|
||||
private bool _descendingSort = false;
|
||||
private string _reportFilePath;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@ -45,113 +45,176 @@ namespace YooAsset.Editor
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_assetListView.selectionChanged += AssetListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
_assetTableView = _root.Q<TableView>("TopTableView");
|
||||
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
|
||||
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
|
||||
CreateAssetTableViewColumns();
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
_dependTableView = _root.Q<TableView>("BottomTableView");
|
||||
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||
CreateDependTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
#endif
|
||||
}
|
||||
private void CreateAssetTableViewColumns()
|
||||
{
|
||||
// AssetPath
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_assetTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//MainBundle
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("MainBundle", "Main Bundle", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_assetTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateDependTableViewColumns()
|
||||
{
|
||||
// DependBundles
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileSize
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("FileSize", "File Size", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
long fileSize = (long)cell.CellValue;
|
||||
infoLabel.text = EditorUtility.FormatBytes(fileSize);
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileHash
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("FileHash", "File Hash", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_searchKeyWord = searchKeyWord;
|
||||
RefreshView();
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterAndSortViewItems();
|
||||
_assetListView.Rebuild();
|
||||
RefreshSortingSymbol();
|
||||
}
|
||||
private List<ReportAssetInfo> FilterAndSortViewItems()
|
||||
{
|
||||
List<ReportAssetInfo> result = new List<ReportAssetInfo>(_buildReport.AssetInfos.Count);
|
||||
_reportFilePath = reprotFilePath;
|
||||
|
||||
// 过滤列表
|
||||
// 清空旧数据
|
||||
_assetTableView.ClearAll(false, true);
|
||||
_dependTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_buildReport.AssetInfos.Count);
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
||||
{
|
||||
if (assetInfo.AssetPath.Contains(_searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(assetInfo);
|
||||
var rowData = new AssetTableData();
|
||||
rowData.AssetInfo = assetInfo;
|
||||
rowData.AddAssetPathCell("AssetPath", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("MainBundle", assetInfo.MainBundleName);
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
_assetTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 排序列表
|
||||
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.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.MainBundleName).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.MainBundleName).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
private void RefreshSortingSymbol()
|
||||
{
|
||||
// 刷新符号
|
||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
||||
_topBar2.text = "Main Bundle";
|
||||
|
||||
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.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar2.text = "Main Bundle ↓";
|
||||
else
|
||||
_topBar2.text = "Main Bundle ↑";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
// 重建视图
|
||||
_assetTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -170,157 +233,61 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 资源列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
private void OnAssetTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var assetTableData = data as AssetTableData;
|
||||
ReportAssetInfo assetInfo = assetTableData.AssetInfo;
|
||||
|
||||
{
|
||||
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 = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<ReportAssetInfo>;
|
||||
var assetInfo = sourceData[index];
|
||||
var bundleInfo = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = assetInfo.AssetPath;
|
||||
|
||||
// Main Bundle
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = bundleInfo.BundleName;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
ReportAssetInfo assetInfo = item as ReportAssetInfo;
|
||||
FillDependListView(assetInfo);
|
||||
}
|
||||
}
|
||||
private void TopBar1_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.AssetPath)
|
||||
{
|
||||
_sortMode = ESortMode.AssetPath;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar2_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleName)
|
||||
{
|
||||
_sortMode = ESortMode.BundleName;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
// 依赖列表相关
|
||||
private void FillDependListView(ReportAssetInfo assetInfo)
|
||||
{
|
||||
List<ReportBundleInfo> bundles = new List<ReportBundleInfo>();
|
||||
// 填充依赖数据
|
||||
var mainBundle = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
||||
bundles.Add(mainBundle);
|
||||
var sourceDatas = new List<ITableData>(mainBundle.DependBundles.Count);
|
||||
foreach (string dependBundleName in mainBundle.DependBundles)
|
||||
{
|
||||
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
||||
bundles.Add(dependBundle);
|
||||
var rowData = new DependTableData();
|
||||
rowData.BundleInfo = dependBundle;
|
||||
rowData.AddStringValueCell("DependBundles", dependBundle.BundleName);
|
||||
rowData.AddLongValueCell("FileSize", dependBundle.FileSize);
|
||||
rowData.AddStringValueCell("FileHash", dependBundle.FileHash);
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = bundles;
|
||||
_dependListView.Rebuild();
|
||||
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
||||
_dependTableView.itemsSource = sourceDatas;
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
private VisualElement MakeDependListViewItem()
|
||||
private void OnClickAssetTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
foreach (var cell in data.Cells)
|
||||
{
|
||||
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);
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
List<ReportBundleInfo> bundles = _dependListView.itemsSource as List<ReportBundleInfo>;
|
||||
ReportBundleInfo bundleInfo = bundles[index];
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
var dependTableData = data as DependTableData;
|
||||
if (dependTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.FileSize);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.FileHash;
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{dependTableData.BundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar2" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
|
||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@ -12,29 +12,25 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterBundleListViewer
|
||||
{
|
||||
private enum ESortMode
|
||||
private class BundleTableData : DefaultTableData
|
||||
{
|
||||
BundleName,
|
||||
BundleSize,
|
||||
BundleTags
|
||||
public ReportBundleInfo BundleInfo;
|
||||
}
|
||||
private class IncludeTableData : DefaultTableData
|
||||
{
|
||||
public ReportAssetInfo AssetInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ToolbarButton _topBar1;
|
||||
private ToolbarButton _topBar2;
|
||||
private ToolbarButton _topBar3;
|
||||
private ToolbarButton _topBar5;
|
||||
private ToolbarButton _bottomBar1;
|
||||
private ListView _bundleListView;
|
||||
private ListView _includeListView;
|
||||
private TableView _bundleTableView;
|
||||
private TableView _includeTableView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private string _searchKeyWord;
|
||||
private ESortMode _sortMode = ESortMode.BundleName;
|
||||
private bool _descendingSort = false;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@ -49,134 +45,243 @@ namespace YooAsset.Editor
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 顶部按钮栏
|
||||
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
|
||||
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
|
||||
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
|
||||
_topBar5 = _root.Q<ToolbarButton>("TopBar5");
|
||||
_topBar1.clicked += TopBar1_clicked;
|
||||
_topBar2.clicked += TopBar2_clicked;
|
||||
_topBar3.clicked += TopBar3_clicked;
|
||||
_topBar5.clicked += TopBar4_clicked;
|
||||
|
||||
// 底部按钮栏
|
||||
_bottomBar1 = _root.Q<ToolbarButton>("BottomBar1");
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
_bundleTableView = _root.Q<TableView>("TopTableView");
|
||||
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||
CreateBundleTableViewColumns();
|
||||
|
||||
// 包含列表
|
||||
_includeListView = _root.Q<ListView>("BottomListView");
|
||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
||||
_includeListView.bindItem = BindIncludeListViewItem;
|
||||
_includeTableView = _root.Q<TableView>("BottomTableView");
|
||||
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
|
||||
CreateIncludeTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
#endif
|
||||
}
|
||||
private void CreateBundleTableViewColumns()
|
||||
{
|
||||
//BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileSize
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("FileSize", "File Size", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
long fileSize = (long)cell.CellValue;
|
||||
infoLabel.text = EditorUtility.FormatBytes(fileSize);
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileHash
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("FileHash", "File Hash", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//Encrypted
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Encrypted", "Encrypted", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
bool encrypted = (bool)cell.CellValue;
|
||||
infoLabel.text = encrypted.ToString();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//Tags
|
||||
{
|
||||
var columnStyle = new ColumnStyle(150, 100, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Tags", "Tags", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateIncludeTableViewColumns()
|
||||
{
|
||||
//IncludeAssets
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("IncludeAssets", "Include Assets", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//AssetSource
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("AssetSource", "Asset Source", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//AssetGUID
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("AssetGUID", "Asset GUID", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
_searchKeyWord = searchKeyWord;
|
||||
RefreshView();
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterAndSortViewItems();
|
||||
_bundleListView.Rebuild();
|
||||
RefreshSortingSymbol();
|
||||
}
|
||||
private List<ReportBundleInfo> FilterAndSortViewItems()
|
||||
{
|
||||
List<ReportBundleInfo> result = new List<ReportBundleInfo>(_buildReport.BundleInfos.Count);
|
||||
|
||||
// 过滤列表
|
||||
// 清空旧数据
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_includeTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_buildReport.BundleInfos.Count);
|
||||
foreach (var bundleInfo in _buildReport.BundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(_searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(bundleInfo);
|
||||
var rowData = new BundleTableData();
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("FileSize", bundleInfo.FileSize);
|
||||
rowData.AddStringValueCell("FileHash", bundleInfo.FileHash);
|
||||
rowData.AddBoolValueCell("Encrypted", bundleInfo.Encrypted);
|
||||
rowData.AddStringValueCell("Tags", string.Join(";", bundleInfo.Tags));
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
_bundleTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 排序列表
|
||||
if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.BundleName).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.BundleName).ToList();
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleSize)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.FileSize).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.FileSize).ToList();
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if (_descendingSort)
|
||||
return result.OrderByDescending(a => a.GetTagsString()).ToList();
|
||||
else
|
||||
return result.OrderBy(a => a.GetTagsString()).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
private void RefreshSortingSymbol()
|
||||
{
|
||||
// 刷新符号
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
||||
_topBar2.text = "Size";
|
||||
_topBar3.text = "Hash";
|
||||
_topBar5.text = "Tags";
|
||||
|
||||
if (_sortMode == ESortMode.BundleName)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↓";
|
||||
else
|
||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↑";
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleSize)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar2.text = "Size ↓";
|
||||
else
|
||||
_topBar2.text = "Size ↑";
|
||||
}
|
||||
else if (_sortMode == ESortMode.BundleTags)
|
||||
{
|
||||
if (_descendingSort)
|
||||
_topBar5.text = "Tags ↓";
|
||||
else
|
||||
_topBar5.text = "Tags ↑";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
/// <summary>
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
// 重建视图
|
||||
_bundleTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -195,241 +300,78 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var bundleTableData = data as BundleTableData;
|
||||
var bundleInfo = bundleTableData.BundleInfo;
|
||||
|
||||
{
|
||||
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 = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
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 = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label6";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 80;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<ReportBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = EditorUtility.FormatBytes(bundleInfo.FileSize);
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.FileHash;
|
||||
|
||||
// Encrypted
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = bundleInfo.Encrypted.ToString();
|
||||
|
||||
// Tags
|
||||
var label6 = element.Q<Label>("Label6");
|
||||
label6.text = bundleInfo.GetTagsString();
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
ReportBundleInfo bundleInfo = item as ReportBundleInfo;
|
||||
FillIncludeListView(bundleInfo);
|
||||
ShowAssetBundleInspector(bundleInfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void ShowAssetBundleInspector(ReportBundleInfo bundleInfo)
|
||||
{
|
||||
if (_buildReport.Summary.BuildPipeline == nameof(EBuildPipeline.RawFileBuildPipeline))
|
||||
return;
|
||||
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{bundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
private void TopBar1_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleName)
|
||||
{
|
||||
_sortMode = ESortMode.BundleName;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar2_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleSize)
|
||||
{
|
||||
_sortMode = ESortMode.BundleSize;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
private void TopBar3_clicked()
|
||||
{
|
||||
}
|
||||
private void TopBar4_clicked()
|
||||
{
|
||||
if (_sortMode != ESortMode.BundleTags)
|
||||
{
|
||||
_sortMode = ESortMode.BundleTags;
|
||||
_descendingSort = false;
|
||||
RefreshView();
|
||||
}
|
||||
else
|
||||
{
|
||||
_descendingSort = !_descendingSort;
|
||||
RefreshView();
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private void FillIncludeListView(ReportBundleInfo bundleInfo)
|
||||
{
|
||||
List<ReportAssetInfo> containsList = new List<ReportAssetInfo>();
|
||||
HashSet<string> mainAssetDic = new HashSet<string>();
|
||||
// 填充包含数据
|
||||
var sourceDatas = new List<ITableData>();
|
||||
var mainAssetDic = new HashSet<string>();
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
if (assetInfo.MainBundleName == bundleInfo.BundleName)
|
||||
{
|
||||
mainAssetDic.Add(assetInfo.AssetPath);
|
||||
containsList.Add(assetInfo);
|
||||
|
||||
var rowData = new IncludeTableData();
|
||||
rowData.AssetInfo = assetInfo;
|
||||
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("AssetSource", "MainAsset");
|
||||
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
|
||||
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 assetInfo = new ReportAssetInfo();
|
||||
assetInfo.AssetPath = assetPath;
|
||||
assetInfo.AssetGUID = "--";
|
||||
containsList.Add(assetInfo);
|
||||
var rowData = new IncludeTableData();
|
||||
rowData.AssetInfo = null;
|
||||
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
|
||||
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
_includeListView.Clear();
|
||||
_includeListView.ClearSelection();
|
||||
_includeListView.itemsSource = containsList;
|
||||
_includeListView.Rebuild();
|
||||
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
||||
_includeTableView.itemsSource = sourceDatas;
|
||||
_includeTableView.RebuildView();
|
||||
}
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
var bundleTableData = data as BundleTableData;
|
||||
if (bundleTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
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);
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{bundleTableData.BundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
private void OnClickIncludeTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
List<ReportAssetInfo> containsList = _includeListView.itemsSource as List<ReportAssetInfo>;
|
||||
ReportAssetInfo assetInfo = containsList[index];
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = assetInfo.AssetPath;
|
||||
|
||||
// Asset Source
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = assetInfo.AssetGUID != "--" ? "Main Asset" : "Builtin Asset";
|
||||
|
||||
// GUID
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = assetInfo.AssetGUID;
|
||||
foreach (var cell in data.Cells)
|
||||
{
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Encrypted" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
|
||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Include Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Asset Source" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="GUID" display-tooltip-when-elided="true" name="BottomBar2" style="width: 280px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@ -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<ItemWrapper> _items = new List<ItemWrapper>();
|
||||
|
||||
private ScrollView _scrollView;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@ -44,9 +29,7 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 概述列表
|
||||
_listView = _root.Q<ListView>("ListView");
|
||||
_listView.makeItem = MakeListViewItem;
|
||||
_listView.bindItem = BindListViewItem;
|
||||
_scrollView = _root.Q<ScrollView>("ScrollView");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -54,52 +37,49 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
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}"));
|
||||
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 Params", string.Empty));
|
||||
_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("Build Params");
|
||||
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);
|
||||
|
||||
_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)));
|
||||
|
||||
_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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -119,45 +99,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<Label>("TitleLabel");
|
||||
titleLabel.text = name;
|
||||
|
||||
// Value
|
||||
var valueLabel = element.Q<Label>("ValueLabel");
|
||||
valueLabel.text = value;
|
||||
}
|
||||
private VisualElement MakeListViewItem()
|
||||
{
|
||||
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 = 200;
|
||||
element.Add(label);
|
||||
}
|
||||
var titleLabel = new Label();
|
||||
titleLabel.name = "TitleLabel";
|
||||
titleLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
titleLabel.style.marginLeft = 3f;
|
||||
titleLabel.style.width = 200;
|
||||
element.Add(titleLabel);
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
var valueLabel = new Label();
|
||||
valueLabel.name = "ValueLabel";
|
||||
valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
valueLabel.style.marginLeft = 3f;
|
||||
valueLabel.style.flexGrow = 1f;
|
||||
valueLabel.style.width = 150;
|
||||
element.Add(valueLabel);
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var itemWrapper = _items[index];
|
||||
|
||||
// Title
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = itemWrapper.Title;
|
||||
|
||||
// Value
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = itemWrapper.Value;
|
||||
}
|
||||
|
||||
private string ConvertTime(int time)
|
||||
{
|
||||
|
@ -1,9 +1,5 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Info" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Param" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:ScrollView name="ScrollView" horizontal-scroller-visibility="Hidden" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetInfo
|
||||
public class AssetInfo : IComparable<AssetInfo>
|
||||
{
|
||||
private string _fileExtension = null;
|
||||
|
||||
@ -37,6 +37,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public AssetInfo(string assetPath)
|
||||
{
|
||||
AssetPath = assetPath;
|
||||
@ -60,5 +61,10 @@ namespace YooAsset.Editor
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public int CompareTo(AssetInfo other)
|
||||
{
|
||||
return this.AssetPath.CompareTo(other.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
@ -129,6 +129,21 @@ namespace YooAsset.Editor
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region PackageManager
|
||||
public static string GetPackageManagerYooVersion()
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(YooAssets).Assembly);
|
||||
if (packageInfo != null)
|
||||
return packageInfo.version;
|
||||
else
|
||||
return string.Empty;
|
||||
#else
|
||||
return string.Empty;
|
||||
#endif
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region EditorUtility
|
||||
/// <summary>
|
||||
/// 搜集资源
|
||||
@ -559,7 +574,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return path.Replace('\\', '/').Replace("\\", "/"); //替换为Linux路径格式
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 移除路径里的后缀名
|
||||
/// </summary>
|
||||
|
8
Editor/Exntesion.meta
Normal file
8
Editor/Exntesion.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57108573b0656af4fb20588dbfea7484
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Editor/Exntesion/CustomRules.meta
Normal file
8
Editor/Exntesion/CustomRules.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73ef838ec60c36249ba05eaa3c96273e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Editor/Exntesion/CustomRules/CustomAdressRule.cs
Normal file
25
Editor/Exntesion/CustomRules/CustomAdressRule.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using YooAsset.Editor;
|
||||
|
||||
[DisplayName("定位地址: 文件名.智能尾缀")]
|
||||
public class AddressByFileNameAndExt : IAddressRule
|
||||
{
|
||||
public string GetAssetAddress(AddressRuleData data)
|
||||
{
|
||||
var ext = Path.GetExtension(data.AssetPath);
|
||||
if (ext == ".asset")
|
||||
{
|
||||
var a = UnityEditor.AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(data.AssetPath);
|
||||
if (a == null) return ".errortype";
|
||||
var type = a.GetType();
|
||||
var dt = Path.GetFileNameWithoutExtension(data.AssetPath);
|
||||
return dt + $".{type.Name.ToLowerInvariant()}";
|
||||
}
|
||||
|
||||
return Path.GetFileName(data.AssetPath);
|
||||
}
|
||||
}
|
11
Editor/Exntesion/CustomRules/CustomAdressRule.cs.meta
Normal file
11
Editor/Exntesion/CustomRules/CustomAdressRule.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 73aae15a0e1aec742a7e8f05755a2013
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
50
Editor/Exntesion/CustomRules/CustomPackRule.cs
Normal file
50
Editor/Exntesion/CustomRules/CustomPackRule.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using YooAsset.Editor;
|
||||
|
||||
[DisplayName("打包特效纹理(自定义)")]
|
||||
public class PackEffectTexture : IPackRule
|
||||
{
|
||||
private const string PackDirectory = "Assets/Effect/Textures/";
|
||||
|
||||
PackRuleResult IPackRule.GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string assetPath = data.AssetPath;
|
||||
if (assetPath.StartsWith(PackDirectory) == false)
|
||||
throw new Exception($"Only support folder : {PackDirectory}");
|
||||
|
||||
string assetName = Path.GetFileName(assetPath).ToLower();
|
||||
string firstChar = assetName.Substring(0, 1);
|
||||
string bundleName = $"{PackDirectory}effect_texture_{firstChar}";
|
||||
var packRuleResult = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return packRuleResult;
|
||||
}
|
||||
}
|
||||
|
||||
[DisplayName("打包视频(自定义)")]
|
||||
public class PackVideo : IPackRule
|
||||
{
|
||||
public PackRuleResult GetPackRuleResult(PackRuleData data)
|
||||
{
|
||||
string bundleName = RemoveExtension(data.AssetPath);
|
||||
string fileExtension = Path.GetExtension(data.AssetPath);
|
||||
fileExtension = fileExtension.Remove(0, 1);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, fileExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
private string RemoveExtension(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
return str;
|
||||
|
||||
int index = str.LastIndexOf(".");
|
||||
if (index == -1)
|
||||
return str;
|
||||
else
|
||||
return str.Remove(index); //"assets/config/test.unity3d" --> "assets/config/test"
|
||||
}
|
||||
}
|
11
Editor/Exntesion/CustomRules/CustomPackRule.cs.meta
Normal file
11
Editor/Exntesion/CustomRules/CustomPackRule.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff1eb84d9996ca1409e37f45617b1bdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Editor/Exntesion/PackageComparator.meta
Normal file
8
Editor/Exntesion/PackageComparator.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0b4ccec8007a6047aade899b4b74fcf
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
138
Editor/Exntesion/PackageComparator/PackageComparatorWindow.cs
Normal file
138
Editor/Exntesion/PackageComparator/PackageComparatorWindow.cs
Normal file
@ -0,0 +1,138 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class PackageComparatorWindow : EditorWindow
|
||||
{
|
||||
static PackageComparatorWindow _thisInstance;
|
||||
|
||||
[MenuItem("Tools/补丁包比对工具", false, 102)]
|
||||
static void ShowWindow()
|
||||
{
|
||||
if (_thisInstance == null)
|
||||
{
|
||||
_thisInstance = EditorWindow.GetWindow(typeof(PackageComparatorWindow), false, "补丁包比对工具", true) as PackageComparatorWindow;
|
||||
_thisInstance.minSize = new Vector2(800, 600);
|
||||
}
|
||||
_thisInstance.Show();
|
||||
}
|
||||
|
||||
private string _manifestPath1 = string.Empty;
|
||||
private string _manifestPath2 = string.Empty;
|
||||
private readonly List<PackageBundle> _changeList = new List<PackageBundle>();
|
||||
private readonly List<PackageBundle> _newList = new List<PackageBundle>();
|
||||
private Vector2 _scrollPos1;
|
||||
private Vector2 _scrollPos2;
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包1", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (string.IsNullOrEmpty(resultPath))
|
||||
return;
|
||||
_manifestPath1 = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath1);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包2", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (string.IsNullOrEmpty(resultPath))
|
||||
return;
|
||||
_manifestPath2 = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath2);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (string.IsNullOrEmpty(_manifestPath1) == false && string.IsNullOrEmpty(_manifestPath2) == false)
|
||||
{
|
||||
if (GUILayout.Button("比对差异", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
ComparePackage(_changeList, _newList);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
using (new EditorGUI.DisabledScope(false))
|
||||
{
|
||||
int totalCount = _changeList.Count;
|
||||
EditorGUILayout.Foldout(true, $"差异列表 ( {totalCount} )");
|
||||
|
||||
EditorGUI.indentLevel = 1;
|
||||
_scrollPos1 = EditorGUILayout.BeginScrollView(_scrollPos1);
|
||||
{
|
||||
foreach (var bundle in _changeList)
|
||||
{
|
||||
EditorGUILayout.LabelField($"{bundle.BundleName} | {(bundle.FileSize / 1024)}K");
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
EditorGUI.indentLevel = 0;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
using (new EditorGUI.DisabledScope(false))
|
||||
{
|
||||
int totalCount = _newList.Count;
|
||||
EditorGUILayout.Foldout(true, $"新增列表 ( {totalCount} )");
|
||||
|
||||
EditorGUI.indentLevel = 1;
|
||||
_scrollPos2 = EditorGUILayout.BeginScrollView(_scrollPos2);
|
||||
{
|
||||
foreach (var bundle in _newList)
|
||||
{
|
||||
EditorGUILayout.LabelField($"{bundle.BundleName}");
|
||||
}
|
||||
}
|
||||
EditorGUILayout.EndScrollView();
|
||||
EditorGUI.indentLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void ComparePackage(List<PackageBundle> changeList, List<PackageBundle> newList)
|
||||
{
|
||||
changeList.Clear();
|
||||
newList.Clear();
|
||||
|
||||
// 加载补丁清单1
|
||||
byte[] bytesData1 = FileUtility.ReadAllBytes(_manifestPath1);
|
||||
PackageManifest manifest1 = ManifestTools.DeserializeFromBinary(bytesData1);
|
||||
|
||||
// 加载补丁清单1
|
||||
byte[] bytesData2 = FileUtility.ReadAllBytes(_manifestPath2);
|
||||
PackageManifest manifest2 = ManifestTools.DeserializeFromBinary(bytesData2);
|
||||
|
||||
// 拷贝文件列表
|
||||
foreach (var bundle2 in manifest2.BundleList)
|
||||
{
|
||||
if (manifest1.TryGetPackageBundleByBundleName(bundle2.BundleName, out PackageBundle bundle1))
|
||||
{
|
||||
if (bundle2.FileHash != bundle1.FileHash)
|
||||
{
|
||||
changeList.Add(bundle2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newList.Add(bundle2);
|
||||
}
|
||||
}
|
||||
|
||||
// 按字母重新排序
|
||||
changeList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||
newList.Sort((x, y) => string.Compare(x.BundleName, y.BundleName));
|
||||
|
||||
Debug.Log("资源包差异比对完成!");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ff3c700b7f108b48998aa1630a769e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Editor/Exntesion/PackageImporter.meta
Normal file
8
Editor/Exntesion/PackageImporter.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa6624433c5d8e445b1426dcdf0763ba
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
90
Editor/Exntesion/PackageImporter/PackageImporterWindow.cs
Normal file
90
Editor/Exntesion/PackageImporter/PackageImporterWindow.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class PackageImporterWindow : EditorWindow
|
||||
{
|
||||
static PackageImporterWindow _thisInstance;
|
||||
|
||||
[MenuItem("Tools/补丁包导入工具", false, 101)]
|
||||
static void ShowWindow()
|
||||
{
|
||||
if (_thisInstance == null)
|
||||
{
|
||||
_thisInstance = EditorWindow.GetWindow(typeof(PackageImporterWindow), false, "补丁包导入工具", true) as PackageImporterWindow;
|
||||
_thisInstance.minSize = new Vector2(800, 600);
|
||||
}
|
||||
_thisInstance.Show();
|
||||
}
|
||||
|
||||
private string _manifestPath = string.Empty;
|
||||
private string _packageName = "DefaultPackage";
|
||||
|
||||
private void OnGUI()
|
||||
{
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("选择补丁包", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string resultPath = EditorUtility.OpenFilePanel("Find", "Assets/", "bytes");
|
||||
if (!string.IsNullOrEmpty(resultPath))
|
||||
_manifestPath = resultPath;
|
||||
}
|
||||
EditorGUILayout.LabelField(_manifestPath);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
if (string.IsNullOrEmpty(_manifestPath) == false)
|
||||
{
|
||||
if (GUILayout.Button("导入补丁包(全部文件)", GUILayout.MaxWidth(150)))
|
||||
{
|
||||
string streamingAssetsRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
EditorTools.ClearFolder(streamingAssetsRoot);
|
||||
CopyPackageFiles(_manifestPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CopyPackageFiles(string manifestFilePath)
|
||||
{
|
||||
string manifestFileName = Path.GetFileNameWithoutExtension(manifestFilePath);
|
||||
string outputDirectory = Path.GetDirectoryName(manifestFilePath);
|
||||
|
||||
// 加载补丁清单
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||
PackageManifest manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
|
||||
// 拷贝核心文件
|
||||
{
|
||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.bytes";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.bytes";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
{
|
||||
string sourcePath = $"{outputDirectory}/{manifestFileName}.hash";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{manifestFileName}.hash";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(manifest.PackageName);
|
||||
string sourcePath = $"{outputDirectory}/{fileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{fileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
// 拷贝文件列表
|
||||
int fileCount = 0;
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
fileCount++;
|
||||
string sourcePath = $"{outputDirectory}/{packageBundle.FileName}";
|
||||
string destPath = $"{AssetBundleBuilderHelper.GetStreamingAssetsRoot()}/{_packageName}/{packageBundle.FileName}";
|
||||
EditorTools.CopyFile(sourcePath, destPath, true);
|
||||
}
|
||||
|
||||
Debug.Log($"补丁包拷贝完成,一共拷贝了{fileCount}个资源文件");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 699068f8f637708409436199baa62c1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Editor/Exntesion/ShaderVariantCollector.meta
Normal file
8
Editor/Exntesion/ShaderVariantCollector.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dcb9955c15609744a9666bd76f6af3d9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEditor;
|
||||
using YooAsset.Editor;
|
||||
|
||||
public static class ShaderVariantCollectionHelper
|
||||
{
|
||||
public static void ClearCurrentShaderVariantCollection()
|
||||
{
|
||||
EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "ClearCurrentShaderVariantCollection");
|
||||
}
|
||||
public static void SaveCurrentShaderVariantCollection(string savePath)
|
||||
{
|
||||
EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "SaveCurrentShaderVariantCollection", savePath);
|
||||
}
|
||||
public static int GetCurrentShaderVariantCollectionShaderCount()
|
||||
{
|
||||
return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionShaderCount");
|
||||
}
|
||||
public static int GetCurrentShaderVariantCollectionVariantCount()
|
||||
{
|
||||
return (int)EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetCurrentShaderVariantCollectionVariantCount");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取着色器的变种总数量
|
||||
/// </summary>
|
||||
public static string GetShaderVariantCount(string assetPath)
|
||||
{
|
||||
Shader shader = AssetDatabase.LoadAssetAtPath<Shader>(assetPath);
|
||||
var variantCount = EditorTools.InvokeNonPublicStaticMethod(typeof(ShaderUtil), "GetVariantCount", shader, true);
|
||||
return variantCount.ToString();
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab74d4ff4a2805147883de70a1559a0a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,190 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEditor;
|
||||
|
||||
[Serializable]
|
||||
public class ShaderVariantCollectionManifest
|
||||
{
|
||||
[Serializable]
|
||||
public class ShaderVariantElement : IComparable<ShaderVariantElement>
|
||||
{
|
||||
public string SortValue { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Pass type to use in this variant.
|
||||
/// </summary>
|
||||
public PassType PassType;
|
||||
|
||||
/// <summary>
|
||||
/// Array of shader keywords to use in this variant.
|
||||
/// </summary>
|
||||
public string[] Keywords;
|
||||
|
||||
public void MakeSortValue()
|
||||
{
|
||||
string combineKeyword = string.Empty;
|
||||
for (int i = 0; i < Keywords.Length; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
combineKeyword = Keywords[0];
|
||||
else
|
||||
combineKeyword = $"{combineKeyword}+{Keywords[0]}";
|
||||
}
|
||||
|
||||
SortValue = $"{PassType}+{combineKeyword}";
|
||||
}
|
||||
public int CompareTo(ShaderVariantElement other)
|
||||
{
|
||||
return SortValue.CompareTo(other.SortValue);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class ShaderVariantInfo : IComparable<ShaderVariantInfo>
|
||||
{
|
||||
public string SortValue { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 着色器资源路径.
|
||||
/// </summary>
|
||||
public string AssetPath;
|
||||
|
||||
/// <summary>
|
||||
/// 着色器名称
|
||||
/// </summary>
|
||||
public string ShaderName;
|
||||
|
||||
/// <summary>
|
||||
/// 着色器变种总数
|
||||
/// </summary>
|
||||
public int ShaderVariantCount = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 着色器变种列表
|
||||
/// </summary>
|
||||
public List<ShaderVariantElement> ShaderVariantElements = new List<ShaderVariantElement>(1000);
|
||||
|
||||
public void MakeSortValue()
|
||||
{
|
||||
SortValue = AssetPath + "+" + ShaderName;
|
||||
}
|
||||
public int CompareTo(ShaderVariantInfo other)
|
||||
{
|
||||
return SortValue.CompareTo(other.SortValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Number of shaders in this collection
|
||||
/// </summary>
|
||||
public int ShaderTotalCount;
|
||||
|
||||
/// <summary>
|
||||
/// Number of total varians in this collection
|
||||
/// </summary>
|
||||
public int VariantTotalCount;
|
||||
|
||||
/// <summary>
|
||||
/// Shader variants info list.
|
||||
/// </summary>
|
||||
public List<ShaderVariantInfo> ShaderVariantInfos = new List<ShaderVariantInfo>(1000);
|
||||
|
||||
/// <summary>
|
||||
/// 添加着色器变种信息
|
||||
/// </summary>
|
||||
public void AddShaderVariant(string assetPath, string shaderName, PassType passType, string[] keywords)
|
||||
{
|
||||
// 排序Keyword列表
|
||||
List<string> temper = new List<string>(keywords);
|
||||
temper.Sort();
|
||||
|
||||
var info = GetOrCreateShaderVariantInfo(assetPath, shaderName);
|
||||
ShaderVariantElement element = new ShaderVariantElement();
|
||||
element.PassType = passType;
|
||||
element.Keywords = temper.ToArray();
|
||||
element.MakeSortValue();
|
||||
info.ShaderVariantElements.Add(element);
|
||||
info.ShaderVariantCount++;
|
||||
}
|
||||
private ShaderVariantInfo GetOrCreateShaderVariantInfo(string assetPath, string shaderName)
|
||||
{
|
||||
var selectList = ShaderVariantInfos.Where(t => t.ShaderName == shaderName && t.AssetPath == assetPath).ToList();
|
||||
if (selectList.Count == 0)
|
||||
{
|
||||
ShaderVariantInfo newInfo = new ShaderVariantInfo();
|
||||
newInfo.AssetPath = assetPath;
|
||||
newInfo.ShaderName = shaderName;
|
||||
newInfo.MakeSortValue();
|
||||
ShaderVariantInfos.Add(newInfo);
|
||||
return newInfo;
|
||||
}
|
||||
|
||||
if (selectList.Count != 1)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
return selectList[0];
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 解析SVC文件并将数据写入到清单
|
||||
/// </summary>
|
||||
public static ShaderVariantCollectionManifest Extract(ShaderVariantCollection svc)
|
||||
{
|
||||
var manifest = new ShaderVariantCollectionManifest();
|
||||
manifest.ShaderTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
|
||||
manifest.VariantTotalCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionVariantCount();
|
||||
|
||||
using (var so = new SerializedObject(svc))
|
||||
{
|
||||
var shaderArray = so.FindProperty("m_Shaders.Array");
|
||||
if (shaderArray != null && shaderArray.isArray)
|
||||
{
|
||||
for (int i = 0; i < shaderArray.arraySize; ++i)
|
||||
{
|
||||
var shaderRef = shaderArray.FindPropertyRelative($"data[{i}].first");
|
||||
var shaderVariantsArray = shaderArray.FindPropertyRelative($"data[{i}].second.variants");
|
||||
if (shaderRef != null && shaderRef.propertyType == SerializedPropertyType.ObjectReference && shaderVariantsArray != null && shaderVariantsArray.isArray)
|
||||
{
|
||||
var shader = shaderRef.objectReferenceValue as Shader;
|
||||
if (shader == null)
|
||||
{
|
||||
throw new Exception("Invalid shader in ShaderVariantCollection file.");
|
||||
}
|
||||
|
||||
string shaderAssetPath = AssetDatabase.GetAssetPath(shader);
|
||||
string shaderName = shader.name;
|
||||
|
||||
// 添加变种信息
|
||||
for (int j = 0; j < shaderVariantsArray.arraySize; ++j)
|
||||
{
|
||||
var propKeywords = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].keywords");
|
||||
var propPassType = shaderVariantsArray.FindPropertyRelative($"Array.data[{j}].passType");
|
||||
if (propKeywords != null && propPassType != null && propKeywords.propertyType == SerializedPropertyType.String)
|
||||
{
|
||||
string[] keywords = propKeywords.stringValue.Split(' ');
|
||||
PassType pathType = (PassType)propPassType.intValue;
|
||||
manifest.AddShaderVariant(shaderAssetPath, shaderName, pathType, keywords);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 重新排序
|
||||
manifest.ShaderVariantInfos.Sort();
|
||||
foreach (var shaderVariantInfo in manifest.ShaderVariantInfos)
|
||||
{
|
||||
shaderVariantInfo.ShaderVariantElements.Sort();
|
||||
}
|
||||
|
||||
return manifest;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97098b04691f5c046ac4829f1d72f425
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user