mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
126 Commits
2.2.8-prev
...
79e0cf85f9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
79e0cf85f9 | ||
|
|
e996eaa008 | ||
|
|
5088c9e985 | ||
|
|
610b3c6d32 | ||
|
|
cc7290f10e | ||
|
|
576b842368 | ||
|
|
d23c0ba715 | ||
|
|
98e19baebd | ||
|
|
f5947db44a | ||
|
|
e978164329 | ||
|
|
966c8f2efa | ||
|
|
a57fec3d71 | ||
|
|
84844eda20 | ||
|
|
698cdcba61 | ||
|
|
1d6c9393d4 | ||
|
|
b654ac156d | ||
|
|
d133a9a692 | ||
|
|
d55db19f0e | ||
|
|
e3fc3df32c | ||
|
|
f2334da72d | ||
|
|
2902b6c2cf | ||
|
|
dfa95b57b9 | ||
|
|
33a2cf66d0 | ||
|
|
5f52cf5b51 | ||
|
|
9d07905f2d | ||
|
|
26dbe9dfdd | ||
|
|
98c5851071 | ||
|
|
a6ee571d65 | ||
|
|
a138701afe | ||
|
|
e52bdea255 | ||
|
|
068a712a30 | ||
|
|
80a5300648 | ||
|
|
0c36e458f7 | ||
|
|
b2fa52e4c4 | ||
|
|
151e978e5b | ||
|
|
9e806861ec | ||
|
|
a9a9368b9b | ||
|
|
7936ba31ea | ||
|
|
afc456de9a | ||
|
|
a98db0ba83 | ||
|
|
fb8720edd3 | ||
|
|
2aa2a0ac3a | ||
|
|
0531b6ef3a | ||
|
|
24142de11f | ||
|
|
7fad6eb70b | ||
|
|
f60227abdf | ||
|
|
18d6a74c53 | ||
|
|
03d06ba657 | ||
|
|
07086b68c8 | ||
|
|
0a85f3126f | ||
|
|
efa4180340 | ||
|
|
fb06f2aa11 | ||
|
|
ce023cedb8 | ||
|
|
3d1a28a50e | ||
|
|
5d2d0b4168 | ||
|
|
fa985a5a93 | ||
|
|
40f9937b60 | ||
|
|
c543c629c3 | ||
|
|
f861279c49 | ||
|
|
ee89f81d46 | ||
|
|
6d216561f8 | ||
|
|
0a96e583d3 | ||
|
|
c9d263c60d | ||
|
|
2d6488abf4 | ||
|
|
7dfbac4a24 | ||
|
|
7cfe4cb2c9 | ||
|
|
30cba8ca5f | ||
|
|
e9261a0ec0 | ||
|
|
89ee22837d | ||
|
|
939f3747cd | ||
|
|
f72814a51b | ||
|
|
94ee2ba5c1 | ||
|
|
fd9533d63f | ||
|
|
6571faae4e | ||
|
|
e031498d5b | ||
|
|
31a0017351 | ||
|
|
6e8cb0366d | ||
|
|
a02b3fbf6e | ||
|
|
37a663e0e1 | ||
|
|
e925d9892f | ||
|
|
e7907eeaa7 | ||
|
|
644e6655ff | ||
|
|
20c07af504 | ||
|
|
38471cdd6c | ||
|
|
0b5d16bd0e | ||
|
|
203b9994df | ||
|
|
e76bbb6a85 | ||
|
|
4e6c146bde | ||
|
|
7e1dc7ef24 | ||
|
|
698d81a433 | ||
|
|
012f9b9f03 | ||
|
|
12bd282ace | ||
|
|
31a89fa1a3 | ||
|
|
57d1e92e59 | ||
|
|
377fca20d9 | ||
|
|
415f844982 | ||
|
|
cbb8472153 | ||
|
|
c85ced89ef | ||
|
|
d5b8c90c94 | ||
|
|
9bcfb04f91 | ||
|
|
ae0fbd4b10 | ||
|
|
ef4f011cf6 | ||
|
|
7cc985205a | ||
|
|
a38b76eb8f | ||
|
|
9f844912cf | ||
|
|
d72b0b10d4 | ||
|
|
655f756d56 | ||
|
|
912e2c28a3 | ||
|
|
9add447566 | ||
|
|
7c435f6dc0 | ||
|
|
5e2fc84ebf | ||
|
|
793a57647d | ||
|
|
c32e7bc525 | ||
|
|
20fac33efc | ||
|
|
8cf356cadb | ||
|
|
17d2c8bf0a | ||
|
|
3dec5ac004 | ||
|
|
cf2ada8f2b | ||
|
|
c801f601d3 | ||
|
|
6a97704dab | ||
|
|
ee6c8301c4 | ||
|
|
de35f4308d | ||
|
|
3d4ed38f17 | ||
|
|
a84f981147 | ||
|
|
b70d821384 | ||
|
|
bc7c6c1f33 |
@@ -2,6 +2,149 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [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
|
||||||
|
|
||||||
|
- (#438) 修复了纯血鸿蒙加载本地文件失败的问题。
|
||||||
|
- (#445) 修复了小游戏扩展文件系统脚本编译错误。
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- EditorSimulateModeHelper.SimulateBuild()方法变更
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public static PackageInvokeBuildResult SimulateBuild(string packageName);
|
||||||
|
```
|
||||||
|
|
||||||
## [2.2.8-preview] - 2025-01-03
|
## [2.2.8-preview] - 2025-01-03
|
||||||
|
|
||||||
新增了单元测试用例。
|
新增了单元测试用例。
|
||||||
|
|||||||
8
Assets/YooAsset/Editor/AssetArtReporter.meta
Normal file
8
Assets/YooAsset/Editor/AssetArtReporter.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bdbb4647038dcc842802f546c2fedc83
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4048f85b9ff1f424a89a9d6109e6faaf
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b87fc70b750616849942173af3bdfd90
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
26
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs
Normal file
26
Assets/YooAsset/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,
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 97cd7d0d616708e42bc53ed7d88718c9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
88
Assets/YooAsset/Editor/AssetArtReporter/ReportElement.cs
Normal file
88
Assets/YooAsset/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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d61f7ee1a8215bf438071055f0a9cb09
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
128
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs
Normal file
128
Assets/YooAsset/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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 3be8b45a77bb720478379c26da3aa68a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
26
Assets/YooAsset/Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
26
Assets/YooAsset/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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 02caa7ae84ee8294a8904a5aaed420ee
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
118
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs
Normal file
118
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
11
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
221
Assets/YooAsset/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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8524c3deb9b27fe4e8e63f15b9ffaaa3
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
54
Assets/YooAsset/Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
54
Assets/YooAsset/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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 694cf47ade54f2b4fa6e618c1310c476
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/YooAsset/Editor/AssetArtScanner.meta
Normal file
8
Assets/YooAsset/Editor/AssetArtScanner.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9bc1ecc3b72dfc34782fb6926d679f92
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
13
Assets/YooAsset/Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
13
Assets/YooAsset/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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6e7252b59455e5c45af0041ccd24b234
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
132
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
132
Assets/YooAsset/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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c63683b07b7a2454b93539ae6b9f32ea
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bed1ef72d1c03e848a41d5ea115e9870
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 84df5e62e3f1b6746a1263e076b003e1
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fda10f23f6f36bf498b54323fe4f680b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
544
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
544
Assets/YooAsset/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
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bff583b32bbeb7e498920bfdc84dba90
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5bbb873a7bee2924a86c876b67bb2cb4
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
26
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs
Normal file
26
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
11
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs
Normal file
59
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
11
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs
Normal file
32
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
11
Assets/YooAsset/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
Assets/YooAsset/Editor/AssetArtScanner/SchemaInspector.cs
Normal file
45
Assets/YooAsset/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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
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);
|
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetStreamingAssetsRoot()
|
public static string GetStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模拟构建
|
/// 模拟构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static EditorSimulateBuildResult SimulateBuild(EditorSimulateBuildParam buildParam)
|
public static PackageInvokeBuildResult SimulateBuild(PackageInvokeBuildParam buildParam)
|
||||||
{
|
{
|
||||||
string packageName = buildParam.PackageName;
|
string packageName = buildParam.PackageName;
|
||||||
string buildPipelineName = buildParam.BuildPipelineName;
|
string buildPipelineName = buildParam.BuildPipelineName;
|
||||||
@@ -31,7 +31,7 @@ namespace YooAsset.Editor
|
|||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
var reulst = new EditorSimulateBuildResult();
|
var reulst = new PackageInvokeBuildResult();
|
||||||
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||||
return reulst;
|
return reulst;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
|||||||
/// 未被依赖的资源列表
|
/// 未被依赖的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源总数
|
/// 参与构建的资源总数
|
||||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||||
@@ -96,14 +96,14 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建着色器信息类
|
/// 创建空的资源包
|
||||||
/// </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);
|
var bundleInfo = new BuildBundleInfo(bundleName);
|
||||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
_bundleInfoDic.Add(bundleName, bundleInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageNote;
|
public string PackageNote;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 旧版依赖模式
|
||||||
|
/// 说明:兼容YooAssets1.5.x版本
|
||||||
|
/// </summary>
|
||||||
|
public bool LegacyDependency = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空构建缓存文件
|
/// 清空构建缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -58,7 +64,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 使用资源依赖缓存数据库
|
/// 使用资源依赖缓存数据库
|
||||||
/// 说明:开启此项可以极大提高资源收集速度
|
/// 说明:开启此项可以极大提高资源收集速度!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UseAssetDependencyDB = false;
|
public bool UseAssetDependencyDB = false;
|
||||||
|
|
||||||
@@ -67,6 +73,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool EnableSharePackRule = false;
|
public bool EnableSharePackRule = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对单独引用的共享资源进行独立打包
|
||||||
|
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||||
|
/// </summary>
|
||||||
|
public bool SingleReferencedPackAlone = true;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -75,12 +87,12 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源包名称样式
|
/// 资源包名称样式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle = EFileNameStyle.HashName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝选项
|
/// 内置文件的拷贝选项
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildinFileCopyOption BuildinFileCopyOption;
|
public EBuildinFileCopyOption BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 内置文件的拷贝参数
|
/// 内置文件的拷贝参数
|
||||||
@@ -116,16 +128,6 @@ namespace YooAsset.Editor
|
|||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(PackageName))
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
|
||||||
{
|
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
|
||||||
throw new Exception(message);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||||
{
|
{
|
||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||||
@@ -136,6 +138,26 @@ namespace YooAsset.Editor
|
|||||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
if (string.IsNullOrEmpty(BuildPipeline))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineIsNullOrEmpty, "Build pipeline is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (BuildBundleType == (int)EBuildBundleType.Unknown)
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeIsUnknown, $"Build bundle type is unknown {BuildBundleType} !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageName))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
// 设置默认备注信息
|
// 设置默认备注信息
|
||||||
if (string.IsNullOrEmpty(PackageNote))
|
if (string.IsNullOrEmpty(PackageNote))
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace YooAsset.Editor
|
|||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||||
|
manifest.LegacyDependency = buildParameters.LegacyDependency;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
@@ -43,8 +44,8 @@ namespace YooAsset.Editor
|
|||||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||||
|
|
||||||
// 处理资源清单的ID数据
|
// 处理资源清单的资源对象
|
||||||
ProcessPacakgeIDs(manifest);
|
ProcessPacakgeAsset(manifest);
|
||||||
|
|
||||||
// 处理资源包的依赖列表
|
// 处理资源包的依赖列表
|
||||||
if (processBundleDepends)
|
if (processBundleDepends)
|
||||||
@@ -54,6 +55,14 @@ namespace YooAsset.Editor
|
|||||||
if (processBundleTags)
|
if (processBundleTags)
|
||||||
ProcessBundleTags(manifest);
|
ProcessBundleTags(manifest);
|
||||||
|
|
||||||
|
#region YOOASSET_LEGACY_DEPENDENCY
|
||||||
|
if (buildParameters.LegacyDependency)
|
||||||
|
{
|
||||||
|
if (processBundleDepends)
|
||||||
|
ProcessLegacyDependency(context, manifest);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
// 创建补丁清单文本文件
|
// 创建补丁清单文本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
@@ -137,7 +146,7 @@ namespace YooAsset.Editor
|
|||||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
packageAsset.TempDataInEditor = assetInfo;
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -165,9 +174,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 处理资源清单的ID数据
|
/// 处理资源清单的资源对象列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ProcessPacakgeIDs(PackageManifest manifest)
|
private void ProcessPacakgeAsset(PackageManifest manifest)
|
||||||
{
|
{
|
||||||
// 注意:优先缓存资源包索引
|
// 注意:优先缓存资源包索引
|
||||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
@@ -176,10 +185,11 @@ namespace YooAsset.Editor
|
|||||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录资源对象所属的资源包ID
|
||||||
foreach (var packageAsset in manifest.AssetList)
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
{
|
{
|
||||||
string bundleName = packageAsset.BundleNameInEditor;
|
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +202,7 @@ namespace YooAsset.Editor
|
|||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
string[] depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||||
List<int> dependIDs = new List<int>(depends.Length);
|
List<int> dependIDs = new List<int>(depends.Length);
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependBundleName in depends)
|
||||||
{
|
{
|
||||||
@@ -264,5 +274,140 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否包含该资源包的索引ID
|
||||||
|
/// </summary>
|
||||||
|
private bool ContainsCachedBundleIndexID(string bundleName)
|
||||||
|
{
|
||||||
|
return _cachedBundleIndexIDs.ContainsKey(bundleName);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region YOOASSET_LEGACY_DEPENDENCY
|
||||||
|
private class DependencyQuery
|
||||||
|
{
|
||||||
|
private readonly HashSet<int> _dependIDs;
|
||||||
|
|
||||||
|
public DependencyQuery(int[] dependIDs)
|
||||||
|
{
|
||||||
|
_dependIDs = new HashSet<int>(dependIDs);
|
||||||
|
}
|
||||||
|
public bool Contains(int bundleID)
|
||||||
|
{
|
||||||
|
return _dependIDs.Contains(bundleID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ProcessLegacyDependency(BuildContext context, PackageManifest manifest)
|
||||||
|
{
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
var dependIDs = packageBundle.DependIDs;
|
||||||
|
packageBundle.TempDataInEditor = new DependencyQuery(dependIDs);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录资源对象依赖的资源包ID集合
|
||||||
|
// 注意:依赖关系非引擎构建结果里查询!
|
||||||
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
|
{
|
||||||
|
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||||
|
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录引用该资源包的资源包ID集合
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
packageBundle.ReferenceBundleIDs = GetBundleReferenceBundleIDs(manifest, packageBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||||
|
// 注意:该步骤依赖前面的操作!
|
||||||
|
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||||
|
if (buildResultContext != null)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
private int[] GetBundleReferenceBundleIDs(PackageManifest manifest, PackageBundle queryBundle)
|
||||||
|
{
|
||||||
|
int queryBundleID = GetCachedBundleIndexID(queryBundle.BundleName);
|
||||||
|
List<int> result = new List<int>();
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
if (packageBundle == queryBundle)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var dependencyQuery = packageBundle.TempDataInEditor as DependencyQuery;
|
||||||
|
if (dependencyQuery.Contains(queryBundleID))
|
||||||
|
{
|
||||||
|
int referenceBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||||
|
if (result.Contains(referenceBundleID) == false)
|
||||||
|
result.Add(referenceBundleID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,7 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
buildReport.Summary.LegacyDependency = buildParameters.LegacyDependency;
|
||||||
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
||||||
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
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;
|
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||||
|
|
||||||
// 2. 剔除未被引用的依赖项资源
|
// 2. 剔除未被引用的依赖项资源
|
||||||
@@ -109,15 +109,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
if (buildAssetInfo.HasBundleName() == false)
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
{
|
{
|
||||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
ProcessingPackShareBundle(buildParameters, collectResult.Command, buildAssetInfo);
|
||||||
if (packRuleResult.IsValid())
|
|
||||||
{
|
|
||||||
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
|
||||||
buildAssetInfo.SetBundleName(shareBundleName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PostProcessPackShareBundle();
|
PostProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 8. 记录关键信息
|
// 8. 记录关键信息
|
||||||
@@ -209,21 +204,38 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 共享资源打包后置处理
|
/// 共享资源打包机制
|
||||||
/// </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>
|
// 处理单个引用的共享资源
|
||||||
/// 获取共享资源包名称
|
if (buildAssetInfo.GetReferenceBundleCount() <= 1)
|
||||||
/// </summary>
|
{
|
||||||
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
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);
|
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包后置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PostProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,8 @@ namespace YooAsset.Editor
|
|||||||
public class BuildResultContext : IContextObject
|
public class BuildResultContext : IContextObject
|
||||||
{
|
{
|
||||||
public IBundleBuildResults Results;
|
public IBundleBuildResults Results;
|
||||||
|
public string BuiltinShadersBundleName;
|
||||||
|
public string MonoScriptsBundleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
@@ -27,7 +29,9 @@ namespace YooAsset.Editor
|
|||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
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);
|
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||||
if (exitCode < 0)
|
if (exitCode < 0)
|
||||||
{
|
{
|
||||||
@@ -35,18 +39,24 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception(message);
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建着色器信息
|
// 说明:解决因为特殊资源包导致验证失败。
|
||||||
// 说明:解决因为着色器资源包导致验证失败。
|
|
||||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
if (string.IsNullOrEmpty(builtinShadersBundleName) == false)
|
||||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
|
||||||
{
|
{
|
||||||
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!");
|
BuildLogger.Log("UnityEngine build success!");
|
||||||
BuildResultContext buildResultContext = new BuildResultContext();
|
BuildResultContext buildResultContext = new BuildResultContext();
|
||||||
buildResultContext.Results = buildResults;
|
buildResultContext.Results = buildResults;
|
||||||
|
buildResultContext.BuiltinShadersBundleName = builtinShadersBundleName;
|
||||||
|
buildResultContext.MonoScriptsBundleName = monoScriptsBundleName;
|
||||||
context.SetContextObject(buildResultContext);
|
context.SetContextObject(buildResultContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
{
|
{
|
||||||
public static class SBPBuildTasks
|
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>();
|
var buildTasks = new List<IBuildTask>();
|
||||||
|
|
||||||
@@ -30,8 +30,8 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
buildTasks.Add(new StripUnusedSpriteSources());
|
buildTasks.Add(new StripUnusedSpriteSources());
|
||||||
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
||||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||||
if (string.IsNullOrEmpty(unityMonoScriptsBundleName) == false)
|
if (string.IsNullOrEmpty(monoScriptsBundleName) == false)
|
||||||
buildTasks.Add(new CreateMonoScriptBundle(unityMonoScriptsBundleName));
|
buildTasks.Add(new CreateMonoScriptBundle(monoScriptsBundleName));
|
||||||
buildTasks.Add(new PostDependencyCallback());
|
buildTasks.Add(new PostDependencyCallback());
|
||||||
|
|
||||||
// Packing
|
// Packing
|
||||||
|
|||||||
@@ -41,6 +41,17 @@ namespace YooAsset.Editor
|
|||||||
public int CacheServerPort;
|
public int CacheServerPort;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置着色器资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public string BuiltinShadersBundleName;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mono脚本资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public string MonoScriptsBundleName;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取可编程构建管线的构建参数
|
/// 获取可编程构建管线的构建参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清空所有情景对象
|
/// 清空所有上下文对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearAllContext()
|
public void ClearAllContext()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置情景对象
|
/// 设置上下文对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetContextObject(IContextObject contextObject)
|
public void SetContextObject(IContextObject contextObject)
|
||||||
{
|
{
|
||||||
@@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取情景对象
|
/// 获取上下文对象
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public T GetContextObject<T>() where T : IContextObject
|
public T GetContextObject<T>() where T : IContextObject
|
||||||
{
|
{
|
||||||
@@ -46,5 +46,21 @@ namespace YooAsset.Editor
|
|||||||
throw new Exception($"Not found context object : {type}");
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,6 +12,8 @@ namespace YooAsset.Editor
|
|||||||
BuildOutputRootIsNullOrEmpty = 113,
|
BuildOutputRootIsNullOrEmpty = 113,
|
||||||
BuildinFileRootIsNullOrEmpty = 114,
|
BuildinFileRootIsNullOrEmpty = 114,
|
||||||
PackageOutputDirectoryExists = 115,
|
PackageOutputDirectoryExists = 115,
|
||||||
|
BuildPipelineIsNullOrEmpty = 116,
|
||||||
|
BuildBundleTypeIsUnknown = 117,
|
||||||
RecommendScriptBuildPipeline = 130,
|
RecommendScriptBuildPipeline = 130,
|
||||||
|
|
||||||
// TaskGetBuildMap
|
// TaskGetBuildMap
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.LegacyDependency = false;
|
||||||
buildParameters.EnableSharePackRule = true;
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace YooAsset.Editor
|
|||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||||
|
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||||
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
@@ -37,6 +38,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.LegacyDependency = false;
|
||||||
buildParameters.EnableSharePackRule = true;
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
@@ -45,6 +47,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
|
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||||
@@ -52,6 +55,17 @@ namespace YooAsset.Editor
|
|||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置着色器资源包名称
|
||||||
|
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||||
|
/// </summary>
|
||||||
|
private string GetBuiltinShaderBundleName()
|
||||||
|
{
|
||||||
|
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||||
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -98,9 +98,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取打包收集的资源文件
|
/// 获取收集的资源列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command)
|
public List<CollectAssetInfo> GetCollectAssets(CollectCommand command)
|
||||||
{
|
{
|
||||||
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(10000);
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 返回列表
|
// 返回结果
|
||||||
return result.Values.ToList();
|
return result.Values.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,10 +86,16 @@ namespace YooAsset.Editor
|
|||||||
return package.GetAllTags();
|
return package.GetAllTags();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[Obsolete("This method will be removed in a future ! Use BeginCollect instead.", true)]
|
||||||
/// 获取包裹收集的资源文件
|
|
||||||
/// </summary>
|
|
||||||
public CollectResult GetPackageAssets(bool simulateBuild, bool useAssetDependencyDB, string packageName)
|
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))
|
if (string.IsNullOrEmpty(packageName))
|
||||||
throw new Exception("Build package name is null or empty !");
|
throw new Exception("Build package name is null or empty !");
|
||||||
@@ -100,16 +106,18 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 创建资源收集命令
|
// 创建资源收集命令
|
||||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||||
CollectCommand command = new CollectCommand(simulateBuild, useAssetDependencyDB, packageName,
|
var command = new CollectCommand(packageName, ignoreRule);
|
||||||
package.EnableAddressable,
|
command.SimulateBuild = simulateBuild;
|
||||||
package.LocationToLower,
|
command.UniqueBundleName = UniqueBundleName;
|
||||||
package.IncludeAssetGUID,
|
command.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
package.AutoCollectShaders,
|
command.EnableAddressable = package.EnableAddressable;
|
||||||
UniqueBundleName, ignoreRule);
|
command.LocationToLower = package.LocationToLower;
|
||||||
|
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
||||||
|
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||||
|
|
||||||
// 获取收集的资源集合
|
// 开始收集工作
|
||||||
CollectResult collectResult = new CollectResult(command);
|
var collectAssets = package.GetCollectAssets(command);
|
||||||
collectResult.SetCollectAssets(package.GetAllCollectAssets(command));
|
var collectResult = new CollectResult(command, collectAssets);
|
||||||
return collectResult;
|
return collectResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,25 +164,25 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
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);
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
_ignoreRulePopupField.label = "File Ignore Rule";
|
if (selectPackage != null)
|
||||||
_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;
|
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||||
if (selectPackage != null)
|
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||||
{
|
}
|
||||||
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
});
|
||||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
_setting2Container.Add(_ignoreRulePopupField);
|
||||||
}
|
|
||||||
});
|
|
||||||
_setting2Container.Add(_ignoreRulePopupField);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
@@ -995,14 +995,16 @@ namespace YooAsset.Editor
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||||
CollectCommand command = new CollectCommand(true, false,
|
string packageName = _packageNameTxt.value;
|
||||||
_packageNameTxt.value,
|
var command = new CollectCommand(packageName, ignoreRule);
|
||||||
_enableAddressableToogle.value,
|
command.SimulateBuild = true;
|
||||||
_locationToLowerToogle.value,
|
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||||
_includeAssetGUIDToogle.value,
|
command.UseAssetDependencyDB = true;
|
||||||
_autoCollectShadersToogle.value,
|
command.EnableAddressable = _enableAddressableToogle.value;
|
||||||
_uniqueBundleNameToogle.value,
|
command.LocationToLower = _locationToLowerToogle.value;
|
||||||
ignoreRule);
|
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
||||||
|
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
||||||
|
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
<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: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: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: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="RemoveBtn" />
|
||||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||||
@@ -36,9 +36,9 @@
|
|||||||
</ui:VisualElement>
|
</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: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: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 Name" name="PackageName" style="flex-direction: column;" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Package Desc" value="filler text" name="PackageDesc" 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" style="flex-grow: 1;" />
|
<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: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="RemoveBtn" />
|
||||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||||
|
|||||||
@@ -40,13 +40,15 @@ namespace YooAsset.Editor
|
|||||||
_databaseFilePath = databaseFilePath;
|
_databaseFilePath = databaseFilePath;
|
||||||
_database.Clear();
|
_database.Clear();
|
||||||
|
|
||||||
|
FileStream stream = null;
|
||||||
|
BinaryReader reader = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (readCacheDatabaseFile && File.Exists(databaseFilePath))
|
if (readCacheDatabaseFile && File.Exists(databaseFilePath))
|
||||||
{
|
{
|
||||||
// 解析缓存文件
|
// 解析缓存文件
|
||||||
using var stream = File.OpenRead(databaseFilePath);
|
stream = File.OpenRead(databaseFilePath);
|
||||||
using var reader = new BinaryReader(stream);
|
reader = new BinaryReader(stream);
|
||||||
string fileVersion = reader.ReadString();
|
string fileVersion = reader.ReadString();
|
||||||
if (fileVersion != FILE_VERSION)
|
if (fileVersion != FILE_VERSION)
|
||||||
throw new Exception("The database file version not match !");
|
throw new Exception("The database file version not match !");
|
||||||
@@ -85,6 +87,13 @@ namespace YooAsset.Editor
|
|||||||
ClearDatabase(true);
|
ClearDatabase(true);
|
||||||
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (reader != null)
|
||||||
|
reader.Close();
|
||||||
|
if (stream != null)
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
|
|
||||||
// 查找新增或变动资源
|
// 查找新增或变动资源
|
||||||
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
||||||
@@ -114,10 +123,12 @@ namespace YooAsset.Editor
|
|||||||
if (File.Exists(_databaseFilePath))
|
if (File.Exists(_databaseFilePath))
|
||||||
File.Delete(_databaseFilePath);
|
File.Delete(_databaseFilePath);
|
||||||
|
|
||||||
|
FileStream stream = null;
|
||||||
|
BinaryWriter writer = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var stream = File.Create(_databaseFilePath);
|
stream = File.Create(_databaseFilePath);
|
||||||
using var writer = new BinaryWriter(stream);
|
writer = new BinaryWriter(stream);
|
||||||
writer.Write(FILE_VERSION);
|
writer.Write(FILE_VERSION);
|
||||||
writer.Write(_database.Count);
|
writer.Write(_database.Count);
|
||||||
foreach (var assetPair in _database)
|
foreach (var assetPair in _database)
|
||||||
@@ -134,6 +145,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
Debug.LogError($"Failed to save cache database : {ex.Message}");
|
Debug.LogError($"Failed to save cache database : {ex.Message}");
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (writer != null)
|
||||||
|
writer.Close();
|
||||||
|
if (stream != null)
|
||||||
|
stream.Close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -3,75 +3,51 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class CollectCommand
|
public class CollectCommand
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 模拟构建模式
|
|
||||||
/// </summary>
|
|
||||||
public bool SimulateBuild { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 使用资源依赖数据库
|
|
||||||
/// </summary>
|
|
||||||
public bool UseAssetDependencyDB { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
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>
|
||||||
/// 忽略规则实例
|
/// 忽略规则实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IIgnoreRule IgnoreRule { private set; get; }
|
public IIgnoreRule IgnoreRule { private set; get; }
|
||||||
|
|
||||||
|
|
||||||
public CollectCommand(bool simulateBuild, bool useAssetDependencyDB, string packageName,
|
/// <summary>
|
||||||
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
/// 模拟构建模式
|
||||||
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
|
/// </summary>
|
||||||
{
|
public bool SimulateBuild { set; get; }
|
||||||
SimulateBuild = simulateBuild;
|
|
||||||
UseAssetDependencyDB = useAssetDependencyDB;
|
|
||||||
PackageName = packageName;
|
|
||||||
EnableAddressable = enableAddressable;
|
|
||||||
LocationToLower = locationToLower;
|
|
||||||
IncludeAssetGUID = includeAssetGUID;
|
|
||||||
AutoCollectShaders = autoCollectShaders;
|
|
||||||
UniqueBundleName = uniqueBundleName;
|
|
||||||
IgnoreRule = ignoreRule;
|
|
||||||
|
|
||||||
// 着色器统一全名称
|
/// <summary>
|
||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
/// 资源包名唯一化
|
||||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
/// </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;
|
private AssetDependencyCache _assetDependency;
|
||||||
public AssetDependencyCache AssetDependency
|
public AssetDependencyCache AssetDependency
|
||||||
@@ -83,5 +59,11 @@ namespace YooAsset.Editor
|
|||||||
return _assetDependency;
|
return _assetDependency;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CollectCommand(string packageName, IIgnoreRule ignoreRule)
|
||||||
|
{
|
||||||
|
PackageName = packageName;
|
||||||
|
IgnoreRule = ignoreRule;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,12 +15,9 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
public List<CollectAssetInfo> CollectAssets { private set; get; }
|
||||||
|
|
||||||
public CollectResult(CollectCommand command)
|
public CollectResult(CollectCommand command, List<CollectAssetInfo> collectAssets)
|
||||||
{
|
{
|
||||||
Command = command;
|
Command = command;
|
||||||
}
|
|
||||||
public void SetCollectAssets(List<CollectAssetInfo> collectAssets)
|
|
||||||
{
|
|
||||||
CollectAssets = collectAssets;
|
CollectAssets = collectAssets;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -240,8 +240,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_currentReport = debugReport;
|
_currentReport = debugReport;
|
||||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||||
_assetListViewer.FillViewData(debugReport, _searchKeyWord);
|
_assetListViewer.FillViewData(debugReport);
|
||||||
_bundleListViewer.FillViewData(debugReport, _searchKeyWord);
|
_bundleListViewer.FillViewData(debugReport);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,8 +286,8 @@ namespace YooAsset.Editor
|
|||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
if (_currentReport != null)
|
if (_currentReport != null)
|
||||||
{
|
{
|
||||||
_assetListViewer.FillViewData(_currentReport, _searchKeyWord);
|
_assetListViewer.RebuildView(_searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_currentReport, _searchKeyWord);
|
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||||
|
|||||||
@@ -11,12 +11,24 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
internal class DebuggerAssetListViewer
|
internal class DebuggerAssetListViewer
|
||||||
{
|
{
|
||||||
|
private class ProviderTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public DebugProviderInfo ProviderInfo;
|
||||||
|
}
|
||||||
|
private class DependTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public DebugBundleInfo BundleInfo;
|
||||||
|
}
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ListView _assetListView;
|
private TableView _providerTableView;
|
||||||
private ListView _dependListView;
|
private TableView _dependTableView;
|
||||||
|
|
||||||
private DebugReport _debugReport;
|
private DebugReport _debugReport;
|
||||||
|
private List<ITableData> _sourceDatas;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
@@ -32,26 +44,287 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源列表
|
// 资源列表
|
||||||
_assetListView = _root.Q<ListView>("TopListView");
|
_providerTableView = _root.Q<TableView>("TopTableView");
|
||||||
_assetListView.makeItem = MakeAssetListViewItem;
|
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
|
||||||
_assetListView.bindItem = BindAssetListViewItem;
|
CreateAssetTableViewColumns();
|
||||||
#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
|
|
||||||
|
|
||||||
// 依赖列表
|
// 依赖列表
|
||||||
_dependListView = _root.Q<ListView>("BottomListView");
|
_dependTableView = _root.Q<TableView>("BottomTableView");
|
||||||
_dependListView.makeItem = MakeDependListViewItem;
|
CreateDependTableViewColumns();
|
||||||
_dependListView.bindItem = BindDependListViewItem;
|
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#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
|
#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.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>
|
/// <summary>
|
||||||
/// 清空页面
|
/// 清空页面
|
||||||
@@ -59,45 +332,21 @@ namespace YooAsset.Editor
|
|||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
_debugReport = null;
|
||||||
_assetListView.Clear();
|
_providerTableView.ClearAll(false, true);
|
||||||
_assetListView.ClearSelection();
|
_dependTableView.ClearAll(false, true);
|
||||||
_assetListView.itemsSource.Clear();
|
RebuildView(null);
|
||||||
_assetListView.Rebuild();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 重建视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
public void RebuildView(string searchKeyWord)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
// 搜索匹配
|
||||||
_assetListView.Clear();
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
providerInfo.PackageName = packageData.PackageName;
|
// 重建视图
|
||||||
tempList.Add(providerInfo);
|
_providerTableView.RebuildView();
|
||||||
}
|
|
||||||
|
|
||||||
tempList.Sort();
|
|
||||||
result.AddRange(tempList);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -116,194 +365,24 @@ namespace YooAsset.Editor
|
|||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnProviderTableViewSelectionChanged(ITableData data)
|
||||||
// 顶部列表相关
|
|
||||||
private VisualElement MakeAssetListViewItem()
|
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
var providerTableData = data as ProviderTableData;
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
||||||
|
|
||||||
|
// 填充依赖数据
|
||||||
|
var sourceDatas = new List<ITableData>(providerInfo.DependBundleInfos.Count);
|
||||||
|
foreach (var dependBundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var rowData = new DependTableData();
|
||||||
label.name = "Label0";
|
rowData.BundleInfo = dependBundleInfo;
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
||||||
label.style.marginLeft = 3f;
|
rowData.AddLongValueCell("RefCount", dependBundleInfo.RefCount);
|
||||||
//label.style.flexGrow = 1f;
|
rowData.AddStringValueCell("Status", dependBundleInfo.Status.ToString());
|
||||||
label.style.width = 150;
|
sourceDatas.Add(rowData);
|
||||||
element.Add(label);
|
|
||||||
}
|
}
|
||||||
|
_dependTableView.itemsSource = sourceDatas;
|
||||||
{
|
_dependTableView.RebuildView();
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<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;">
|
<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;">
|
<YooAsset.Editor.TableView name="TopTableView" />
|
||||||
<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;" />
|
|
||||||
</ui:VisualElement>
|
</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;">
|
<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;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||||
<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>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -11,12 +11,24 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
internal class DebuggerBundleListViewer
|
internal class DebuggerBundleListViewer
|
||||||
{
|
{
|
||||||
|
private class BundleTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public string PackageName;
|
||||||
|
public DebugBundleInfo BundleInfo;
|
||||||
|
}
|
||||||
|
private class UsingTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public DebugProviderInfo ProviderInfo;
|
||||||
|
}
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ListView _bundleListView;
|
private TableView _bundleTableView;
|
||||||
private ListView _usingListView;
|
private TableView _usingTableView;
|
||||||
|
|
||||||
private DebugReport _debugReport;
|
private DebugReport _debugReport;
|
||||||
|
private List<ITableData> _sourceDatas;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
@@ -32,26 +44,273 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
_bundleListView = _root.Q<ListView>("TopListView");
|
_bundleTableView = _root.Q<TableView>("TopTableView");
|
||||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||||
_bundleListView.bindItem = BindBundleListViewItem;
|
CreateBundleTableViewColumns();
|
||||||
#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
|
|
||||||
|
|
||||||
// 使用列表
|
// 使用列表
|
||||||
_usingListView = _root.Q<ListView>("BottomListView");
|
_usingTableView = _root.Q<TableView>("BottomTableView");
|
||||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
CreateUsingTableViewColumns();
|
||||||
_usingListView.bindItem = BindIncludeListViewItem;
|
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#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
|
#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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 填充页面数据
|
||||||
|
/// </summary>
|
||||||
|
public void FillViewData(DebugReport debugReport)
|
||||||
|
{
|
||||||
|
_debugReport = debugReport;
|
||||||
|
|
||||||
|
// 清空旧数据
|
||||||
|
_bundleTableView.ClearAll(false, true);
|
||||||
|
_usingTableView.ClearAll(false, true);
|
||||||
|
|
||||||
|
// 填充数据源
|
||||||
|
_sourceDatas = new List<ITableData>(1000);
|
||||||
|
foreach (var packageData in debugReport.PackageDatas)
|
||||||
|
{
|
||||||
|
var tempDic = new HashSet<string>();
|
||||||
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
|
{
|
||||||
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
|
{
|
||||||
|
if (tempDic.Contains(bundleInfo.BundleName) == false)
|
||||||
|
{
|
||||||
|
tempDic.Add(bundleInfo.BundleName);
|
||||||
|
|
||||||
|
var rowData = new BundleTableData();
|
||||||
|
rowData.PackageName = packageData.PackageName;
|
||||||
|
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>
|
/// <summary>
|
||||||
/// 清空页面
|
/// 清空页面
|
||||||
@@ -59,52 +318,22 @@ namespace YooAsset.Editor
|
|||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
_debugReport = null;
|
||||||
_bundleListView.Clear();
|
_bundleTableView.ClearAll(false, true);
|
||||||
_bundleListView.ClearSelection();
|
_bundleTableView.RebuildView();
|
||||||
_bundleListView.itemsSource.Clear();
|
_usingTableView.ClearAll(false, true);
|
||||||
_bundleListView.Rebuild();
|
_usingTableView.RebuildView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 填充页面数据
|
/// 重建视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
public void RebuildView(string searchKeyWord)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
// 搜索匹配
|
||||||
_bundleListView.Clear();
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
// 重建视图
|
||||||
{
|
_bundleTableView.RebuildView();
|
||||||
bundleInfo.PackageName = pakcageData.PackageName;
|
|
||||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var tempList = tempDic.Values.ToList();
|
|
||||||
tempList.Sort();
|
|
||||||
result.AddRange(tempList);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -123,199 +352,38 @@ namespace YooAsset.Editor
|
|||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||||
// 顶部列表相关
|
|
||||||
private VisualElement MakeBundleListViewItem()
|
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
var bundleTableData = data as BundleTableData;
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
|
||||||
|
|
||||||
{
|
// 填充依赖数据
|
||||||
var label = new Label();
|
var sourceDatas = new List<ITableData>(1000);
|
||||||
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)
|
foreach (var packageData in _debugReport.PackageDatas)
|
||||||
{
|
{
|
||||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
if (packageData.PackageName != bundleTableData.PackageName)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (var providerInfo in packageData.ProviderInfos)
|
||||||
{
|
{
|
||||||
foreach (var providerInfo in packageData.ProviderInfos)
|
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||||
{
|
{
|
||||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
if (bundleInfo.BundleName == bundleTableData.BundleInfo.BundleName)
|
||||||
{
|
{
|
||||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
var rowData = new UsingTableData();
|
||||||
{
|
rowData.ProviderInfo = providerInfo;
|
||||||
source.Add(providerInfo);
|
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
|
||||||
continue;
|
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;
|
||||||
_usingListView.Clear();
|
_usingTableView.RebuildView();
|
||||||
_usingListView.ClearSelection();
|
|
||||||
_usingListView.itemsSource = source;
|
|
||||||
_usingListView.Rebuild();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<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;">
|
<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;">
|
<YooAsset.Editor.TableView name="TopTableView" />
|
||||||
<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;" />
|
|
||||||
</ui:VisualElement>
|
</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;">
|
<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;">
|
<YooAsset.Editor.TableView name="BottomTableView" />
|
||||||
<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>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -112,16 +112,16 @@ namespace YooAsset.Editor
|
|||||||
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
string jsonData = FileUtility.ReadAllText(_reportFilePath);
|
||||||
_buildReport = BuildReport.Deserialize(jsonData);
|
_buildReport = BuildReport.Deserialize(jsonData);
|
||||||
_summaryViewer.FillViewData(_buildReport);
|
_summaryViewer.FillViewData(_buildReport);
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_assetListViewer.FillViewData(_buildReport, _reportFilePath);
|
||||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
_bundleListViewer.FillViewData(_buildReport, _reportFilePath);
|
||||||
}
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
{
|
{
|
||||||
_searchKeyWord = e.newValue;
|
_searchKeyWord = e.newValue;
|
||||||
if (_buildReport != null)
|
if (_buildReport != null)
|
||||||
{
|
{
|
||||||
_assetListViewer.FillViewData(_buildReport, _searchKeyWord);
|
_assetListViewer.RebuildView(_searchKeyWord);
|
||||||
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
|
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ViewModeMenuAction0(DropdownMenuAction action)
|
private void ViewModeMenuAction0(DropdownMenuAction action)
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ namespace YooAsset.Editor
|
|||||||
public string IgnoreRuleName;
|
public string IgnoreRuleName;
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
public bool LegacyDependency;
|
||||||
public bool ClearBuildCacheFiles;
|
public bool ClearBuildCacheFiles;
|
||||||
public bool UseAssetDependencyDB;
|
public bool UseAssetDependencyDB;
|
||||||
public bool EnableSharePackRule;
|
public bool EnableSharePackRule;
|
||||||
|
|||||||
@@ -6,30 +6,30 @@ using UnityEditor;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor.UIElements;
|
using UnityEditor.UIElements;
|
||||||
using UnityEngine.UIElements;
|
using UnityEngine.UIElements;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class ReporterAssetListViewer
|
internal class ReporterAssetListViewer
|
||||||
{
|
{
|
||||||
private enum ESortMode
|
private class AssetTableData : DefaultTableData
|
||||||
{
|
{
|
||||||
AssetPath,
|
public ReportAssetInfo AssetInfo;
|
||||||
BundleName
|
}
|
||||||
|
private class DependTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public ReportBundleInfo BundleInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ToolbarButton _topBar1;
|
private TableView _assetTableView;
|
||||||
private ToolbarButton _topBar2;
|
private TableView _dependTableView;
|
||||||
private ToolbarButton _bottomBar1;
|
|
||||||
private ListView _assetListView;
|
|
||||||
private ListView _dependListView;
|
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
private string _searchKeyWord;
|
private string _reportFilePath;
|
||||||
private ESortMode _sortMode = ESortMode.AssetPath;
|
private List<ITableData> _sourceDatas;
|
||||||
private bool _descendingSort = false;
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -45,113 +45,174 @@ namespace YooAsset.Editor
|
|||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_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");
|
_assetTableView = _root.Q<TableView>("TopTableView");
|
||||||
_assetListView.makeItem = MakeAssetListViewItem;
|
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
|
||||||
_assetListView.bindItem = BindAssetListViewItem;
|
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
|
||||||
#if UNITY_2022_3_OR_NEWER
|
CreateAssetTableViewColumns();
|
||||||
_assetListView.selectionChanged += AssetListView_onSelectionChange;
|
|
||||||
#elif UNITY_2020_1_OR_NEWER
|
|
||||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
|
||||||
#else
|
|
||||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 依赖列表
|
// 依赖列表
|
||||||
_dependListView = _root.Q<ListView>("BottomListView");
|
_dependTableView = _root.Q<TableView>("BottomTableView");
|
||||||
_dependListView.makeItem = MakeDependListViewItem;
|
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||||
_dependListView.bindItem = BindDependListViewItem;
|
CreateDependTableViewColumns();
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
private void CreateAssetTableViewColumns()
|
||||||
|
{
|
||||||
|
// 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();
|
||||||
|
};
|
||||||
|
_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;
|
||||||
|
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>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(BuildReport buildReport, string searchKeyWord)
|
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
_searchKeyWord = searchKeyWord;
|
_reportFilePath = reprotFilePath;
|
||||||
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);
|
|
||||||
|
|
||||||
// 过滤列表
|
// 清空旧数据
|
||||||
|
_assetTableView.ClearAll(false, true);
|
||||||
|
_dependTableView.ClearAll(false, true);
|
||||||
|
|
||||||
|
// 填充数据源
|
||||||
|
_sourceDatas = new List<ITableData>(_buildReport.AssetInfos.Count);
|
||||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
var rowData = new AssetTableData();
|
||||||
{
|
rowData.AssetInfo = assetInfo;
|
||||||
if (assetInfo.AssetPath.Contains(_searchKeyWord) == false)
|
rowData.AddAssetPathCell("AssetPath", assetInfo.AssetPath);
|
||||||
continue;
|
rowData.AddStringValueCell("MainBundle", assetInfo.MainBundleName);
|
||||||
}
|
_sourceDatas.Add(rowData);
|
||||||
result.Add(assetInfo);
|
|
||||||
}
|
}
|
||||||
|
_assetTableView.itemsSource = _sourceDatas;
|
||||||
|
|
||||||
// 排序列表
|
// 重建视图
|
||||||
if (_sortMode == ESortMode.AssetPath)
|
RebuildView(null);
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void RefreshSortingSymbol()
|
|
||||||
{
|
|
||||||
// 刷新符号
|
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
|
|
||||||
_topBar2.text = "Main Bundle";
|
|
||||||
|
|
||||||
if (_sortMode == ESortMode.AssetPath)
|
/// <summary>
|
||||||
{
|
/// 重建视图
|
||||||
if (_descendingSort)
|
/// </summary>
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↓";
|
public void RebuildView(string searchKeyWord)
|
||||||
else
|
{
|
||||||
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↑";
|
// 搜索匹配
|
||||||
}
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
else if (_sortMode == ESortMode.BundleName)
|
|
||||||
{
|
// 重建视图
|
||||||
if (_descendingSort)
|
_assetTableView.RebuildView();
|
||||||
_topBar2.text = "Main Bundle ↓";
|
|
||||||
else
|
|
||||||
_topBar2.text = "Main Bundle ↑";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new System.NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -170,157 +231,61 @@ namespace YooAsset.Editor
|
|||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnAssetTableViewSelectionChanged(ITableData data)
|
||||||
// 资源列表相关
|
|
||||||
private VisualElement MakeAssetListViewItem()
|
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
var assetTableData = data as AssetTableData;
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
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);
|
var mainBundle = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
||||||
bundles.Add(mainBundle);
|
var sourceDatas = new List<ITableData>(mainBundle.DependBundles.Count);
|
||||||
foreach (string dependBundleName in mainBundle.DependBundles)
|
foreach (string dependBundleName in mainBundle.DependBundles)
|
||||||
{
|
{
|
||||||
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
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);
|
||||||
}
|
}
|
||||||
|
_dependTableView.itemsSource = sourceDatas;
|
||||||
_dependListView.Clear();
|
_dependTableView.RebuildView();
|
||||||
_dependListView.ClearSelection();
|
|
||||||
_dependListView.itemsSource = bundles;
|
|
||||||
_dependListView.Rebuild();
|
|
||||||
_bottomBar1.text = $"Depend Bundles ({bundles.Count})";
|
|
||||||
}
|
}
|
||||||
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();
|
if (cell is AssetPathCell assetPathCell)
|
||||||
label.name = "Label1";
|
{
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
if (assetPathCell.PingAssetObject())
|
||||||
label.style.marginLeft = 3f;
|
break;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 dependTableData = data as DependTableData;
|
||||||
var label1 = element.Q<Label>("Label1");
|
if (dependTableData.BundleInfo.Encrypted)
|
||||||
label1.text = bundleInfo.BundleName;
|
return;
|
||||||
|
|
||||||
// Size
|
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||||
var label2 = element.Q<Label>("Label2");
|
{
|
||||||
label2.text = EditorUtility.FormatBytes(bundleInfo.FileSize);
|
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||||
|
string filePath = $"{rootDirectory}/{dependTableData.BundleInfo.FileName}";
|
||||||
// Hash
|
if (File.Exists(filePath))
|
||||||
var label3 = element.Q<Label>("Label3");
|
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||||
label3.text = bundleInfo.FileHash;
|
else
|
||||||
|
Selection.activeObject = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<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;">
|
<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;">
|
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||||
<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;" />
|
|
||||||
</ui:VisualElement>
|
</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;">
|
<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;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||||
<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>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -12,29 +12,25 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
internal class ReporterBundleListViewer
|
internal class ReporterBundleListViewer
|
||||||
{
|
{
|
||||||
private enum ESortMode
|
private class BundleTableData : DefaultTableData
|
||||||
{
|
{
|
||||||
BundleName,
|
public ReportBundleInfo BundleInfo;
|
||||||
BundleSize,
|
}
|
||||||
BundleTags
|
private class IncludeTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public ReportAssetInfo AssetInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private ToolbarButton _topBar1;
|
private TableView _bundleTableView;
|
||||||
private ToolbarButton _topBar2;
|
private TableView _includeTableView;
|
||||||
private ToolbarButton _topBar3;
|
|
||||||
private ToolbarButton _topBar5;
|
|
||||||
private ToolbarButton _bottomBar1;
|
|
||||||
private ListView _bundleListView;
|
|
||||||
private ListView _includeListView;
|
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
private string _reportFilePath;
|
private string _reportFilePath;
|
||||||
private string _searchKeyWord;
|
private List<ITableData> _sourceDatas;
|
||||||
private ESortMode _sortMode = ESortMode.BundleName;
|
|
||||||
private bool _descendingSort = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化页面
|
/// 初始化页面
|
||||||
@@ -49,134 +45,241 @@ namespace YooAsset.Editor
|
|||||||
_root = _visualAsset.CloneTree();
|
_root = _visualAsset.CloneTree();
|
||||||
_root.style.flexGrow = 1f;
|
_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");
|
_bundleTableView = _root.Q<TableView>("TopTableView");
|
||||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||||
_bundleListView.bindItem = BindBundleListViewItem;
|
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||||
#if UNITY_2022_3_OR_NEWER
|
CreateBundleTableViewColumns();
|
||||||
_bundleListView.selectionChanged += BundleListView_onSelectionChange;
|
|
||||||
#elif UNITY_2020_1_OR_NEWER
|
|
||||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
|
||||||
#else
|
|
||||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 包含列表
|
// 包含列表
|
||||||
_includeListView = _root.Q<ListView>("BottomListView");
|
_includeTableView = _root.Q<TableView>("BottomTableView");
|
||||||
_includeListView.makeItem = MakeIncludeListViewItem;
|
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
|
||||||
_includeListView.bindItem = BindIncludeListViewItem;
|
CreateIncludeTableViewColumns();
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
private void CreateBundleTableViewColumns()
|
||||||
|
{
|
||||||
|
//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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
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>
|
||||||
/// 填充页面数据
|
/// 填充页面数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(BuildReport buildReport, string reprotFilePath, string searchKeyWord)
|
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||||
{
|
{
|
||||||
_buildReport = buildReport;
|
_buildReport = buildReport;
|
||||||
_reportFilePath = reprotFilePath;
|
_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)
|
foreach (var bundleInfo in _buildReport.BundleInfos)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_searchKeyWord) == false)
|
var rowData = new BundleTableData();
|
||||||
{
|
rowData.BundleInfo = bundleInfo;
|
||||||
if (bundleInfo.BundleName.Contains(_searchKeyWord) == false)
|
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||||
continue;
|
rowData.AddLongValueCell("FileSize", bundleInfo.FileSize);
|
||||||
}
|
rowData.AddStringValueCell("FileHash", bundleInfo.FileHash);
|
||||||
result.Add(bundleInfo);
|
rowData.AddBoolValueCell("Encrypted", bundleInfo.Encrypted);
|
||||||
|
rowData.AddStringValueCell("Tags", string.Join(";", bundleInfo.Tags));
|
||||||
|
_sourceDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
|
_bundleTableView.itemsSource = _sourceDatas;
|
||||||
|
|
||||||
// 排序列表
|
// 重建视图
|
||||||
if (_sortMode == ESortMode.BundleName)
|
RebuildView(null);
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private void RefreshSortingSymbol()
|
|
||||||
{
|
|
||||||
// 刷新符号
|
|
||||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count})";
|
|
||||||
_topBar2.text = "Size";
|
|
||||||
_topBar3.text = "Hash";
|
|
||||||
_topBar5.text = "Tags";
|
|
||||||
|
|
||||||
if (_sortMode == ESortMode.BundleName)
|
/// <summary>
|
||||||
{
|
/// 重建视图
|
||||||
if (_descendingSort)
|
/// </summary>
|
||||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↓";
|
public void RebuildView(string searchKeyWord)
|
||||||
else
|
{
|
||||||
_topBar1.text = $"Bundle Name ({_bundleListView.itemsSource.Count}) ↑";
|
// 搜索匹配
|
||||||
}
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
else if (_sortMode == ESortMode.BundleSize)
|
|
||||||
{
|
// 重建视图
|
||||||
if (_descendingSort)
|
_bundleTableView.RebuildView();
|
||||||
_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>
|
||||||
@@ -195,241 +298,78 @@ namespace YooAsset.Editor
|
|||||||
_root.RemoveFromHierarchy();
|
_root.RemoveFromHierarchy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||||
// 顶部列表相关
|
|
||||||
private VisualElement MakeBundleListViewItem()
|
|
||||||
{
|
{
|
||||||
VisualElement element = new VisualElement();
|
var bundleTableData = data as BundleTableData;
|
||||||
element.style.flexDirection = FlexDirection.Row;
|
var bundleInfo = bundleTableData.BundleInfo;
|
||||||
|
|
||||||
{
|
// 填充包含数据
|
||||||
var label = new Label();
|
var sourceDatas = new List<ITableData>();
|
||||||
label.name = "Label1";
|
var mainAssetDic = new HashSet<string>();
|
||||||
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>();
|
|
||||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||||
{
|
{
|
||||||
if (assetInfo.MainBundleName == bundleInfo.BundleName)
|
if (assetInfo.MainBundleName == bundleInfo.BundleName)
|
||||||
{
|
{
|
||||||
mainAssetDic.Add(assetInfo.AssetPath);
|
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 (string assetPath in bundleInfo.AllBuiltinAssets)
|
||||||
{
|
{
|
||||||
if (mainAssetDic.Contains(assetPath) == false)
|
if (mainAssetDic.Contains(assetPath) == false)
|
||||||
{
|
{
|
||||||
var assetInfo = new ReportAssetInfo();
|
var rowData = new IncludeTableData();
|
||||||
assetInfo.AssetPath = assetPath;
|
rowData.AssetInfo = null;
|
||||||
assetInfo.AssetGUID = "--";
|
rowData.AddAssetPathCell("IncludeAssets", assetPath);
|
||||||
containsList.Add(assetInfo);
|
rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
|
||||||
|
rowData.AddStringValueCell("AssetGUID", "--");
|
||||||
|
sourceDatas.Add(rowData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_includeListView.Clear();
|
_includeTableView.itemsSource = sourceDatas;
|
||||||
_includeListView.ClearSelection();
|
_includeTableView.RebuildView();
|
||||||
_includeListView.itemsSource = containsList;
|
|
||||||
_includeListView.Rebuild();
|
|
||||||
_bottomBar1.text = $"Include Assets ({containsList.Count})";
|
|
||||||
}
|
}
|
||||||
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();
|
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||||
label.name = "Label1";
|
string filePath = $"{rootDirectory}/{bundleTableData.BundleInfo.FileName}";
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
if (File.Exists(filePath))
|
||||||
label.style.marginLeft = 3f;
|
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||||
label.style.flexGrow = 1f;
|
else
|
||||||
label.style.width = 280;
|
Selection.activeObject = null;
|
||||||
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 = "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
|
foreach (var cell in data.Cells)
|
||||||
var label1 = element.Q<Label>("Label1");
|
{
|
||||||
label1.text = assetInfo.AssetPath;
|
if (cell is AssetPathCell assetPathCell)
|
||||||
|
{
|
||||||
// Asset Source
|
if (assetPathCell.PingAssetObject())
|
||||||
var label3 = element.Q<Label>("Label3");
|
break;
|
||||||
label3.text = assetInfo.AssetGUID != "--" ? "Main Asset" : "Builtin Asset";
|
}
|
||||||
|
}
|
||||||
// GUID
|
|
||||||
var label2 = element.Q<Label>("Label2");
|
|
||||||
label2.text = assetInfo.AssetGUID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<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;">
|
<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;">
|
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
||||||
<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;" />
|
|
||||||
</ui:VisualElement>
|
</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;">
|
<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;">
|
||||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
||||||
<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>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -75,9 +75,10 @@ namespace YooAsset.Editor
|
|||||||
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
_items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
|
||||||
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
|
||||||
_items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"));
|
_items.Add(new ItemWrapper("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}"));
|
||||||
|
|
||||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||||
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
_items.Add(new ItemWrapper("Build Params", string.Empty));
|
||||||
|
_items.Add(new ItemWrapper("Legacy Dependency Mode", $"{buildReport.Summary.LegacyDependency}"));
|
||||||
_items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}"));
|
_items.Add(new ItemWrapper("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}"));
|
||||||
_items.Add(new ItemWrapper("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}"));
|
_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("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"));
|
||||||
|
|||||||
8
Assets/YooAsset/Editor/UIElements/ElementsDefine.meta
Normal file
8
Assets/YooAsset/Editor/UIElements/ElementsDefine.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5f915322e2be56345a9d145800f7a0e0
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 显示开关(眼睛图标)
|
||||||
|
/// </summary>
|
||||||
|
public class DisplayToggle : Toggle
|
||||||
|
{
|
||||||
|
private readonly VisualElement _checkbox;
|
||||||
|
|
||||||
|
public DisplayToggle()
|
||||||
|
{
|
||||||
|
_checkbox = this.Q<VisualElement>("unity-checkmark");
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 刷新图标
|
||||||
|
/// </summary>
|
||||||
|
public void RefreshIcon()
|
||||||
|
{
|
||||||
|
if (this.value)
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleoff@2x").image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleon@2x").image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 551a9db915a2cf744ac6088e7c634689
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#if UNITY_2020_3_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 分屏控件
|
||||||
|
/// </summary>
|
||||||
|
public class PanelSplitView : TwoPaneSplitView
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<PanelSplitView, UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 竖版分屏
|
||||||
|
/// </summary>
|
||||||
|
public static void SplitVerticalPanel(VisualElement root, VisualElement panelA, VisualElement panelB)
|
||||||
|
{
|
||||||
|
root.Remove(panelA);
|
||||||
|
root.Remove(panelB);
|
||||||
|
|
||||||
|
var spliteView = new PanelSplitView();
|
||||||
|
spliteView.fixedPaneInitialDimension = 300;
|
||||||
|
spliteView.orientation = TwoPaneSplitViewOrientation.Vertical;
|
||||||
|
spliteView.contentContainer.Add(panelA);
|
||||||
|
spliteView.contentContainer.Add(panelB);
|
||||||
|
root.Add(spliteView);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,627 @@
|
|||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ReorderableListView : VisualElement
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<ReorderableListView, UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 制作元素委托
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public delegate VisualElement MakeElementDelegate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定元素委托
|
||||||
|
/// </summary>
|
||||||
|
public delegate void BindElementDelegqate(VisualElement element, int index);
|
||||||
|
|
||||||
|
private Foldout _foldout;
|
||||||
|
private ListView _listView;
|
||||||
|
private Label _headerLabel;
|
||||||
|
private Button _addButton;
|
||||||
|
private Button _removeButton;
|
||||||
|
private string _headerName = nameof(ReorderableListView);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 源数据
|
||||||
|
/// </summary>
|
||||||
|
public IList SourceData
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value is ArrayList)
|
||||||
|
throw new Exception($"{nameof(SourceData)} not support {nameof(ArrayList)}");
|
||||||
|
|
||||||
|
_listView.Clear();
|
||||||
|
_listView.ClearSelection();
|
||||||
|
_listView.itemsSource = value;
|
||||||
|
_listView.Rebuild();
|
||||||
|
RefreshFoldoutName();
|
||||||
|
RefreshRemoveButton();
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _listView.itemsSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 元素固定高度
|
||||||
|
/// </summary>
|
||||||
|
public float ElementHeight
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_listView.fixedItemHeight = value;
|
||||||
|
_listView.Rebuild();
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _listView.fixedItemHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加按钮显隐
|
||||||
|
/// </summary>
|
||||||
|
public bool DisplayAdd
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
UIElementsTools.SetElementVisible(_addButton, value);
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _addButton.style.visibility == Visibility.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 移除按钮显隐
|
||||||
|
/// </summary>
|
||||||
|
public bool DisplayRemove
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
UIElementsTools.SetElementVisible(_removeButton, value);
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _removeButton.style.visibility == Visibility.Visible;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标题名称
|
||||||
|
/// </summary>
|
||||||
|
public string HeaderName
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_headerName = value;
|
||||||
|
RefreshFoldoutName();
|
||||||
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _headerName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 制作元素的回调
|
||||||
|
/// </summary>
|
||||||
|
public MakeElementDelegate MakeElementCallback;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定元素的回调
|
||||||
|
/// </summary>
|
||||||
|
public BindElementDelegqate BindElementCallback;
|
||||||
|
|
||||||
|
|
||||||
|
public ReorderableListView()
|
||||||
|
{
|
||||||
|
CreateView(true);
|
||||||
|
}
|
||||||
|
public ReorderableListView(bool foldout)
|
||||||
|
{
|
||||||
|
CreateView(foldout);
|
||||||
|
}
|
||||||
|
private void CreateView(bool foldout)
|
||||||
|
{
|
||||||
|
this.style.flexGrow = 1;
|
||||||
|
this.style.flexShrink = 1;
|
||||||
|
|
||||||
|
// 折叠栏
|
||||||
|
if (foldout)
|
||||||
|
{
|
||||||
|
_foldout = new Foldout();
|
||||||
|
_foldout.style.flexGrow = 1f;
|
||||||
|
_foldout.style.flexShrink = 1f;
|
||||||
|
_foldout.text = $"{nameof(ReorderableListView)}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_headerLabel = new Label();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 列表视图
|
||||||
|
_listView = new ListView();
|
||||||
|
_listView.style.flexGrow = 1;
|
||||||
|
_listView.style.flexShrink = 1;
|
||||||
|
_listView.reorderable = true;
|
||||||
|
_listView.reorderMode = ListViewReorderMode.Animated;
|
||||||
|
_listView.makeItem = MakeListViewElement;
|
||||||
|
_listView.bindItem = BindListViewElement;
|
||||||
|
#if UNITY_2022_3_OR_NEWER
|
||||||
|
_listView.selectionChanged += OnSelectionChanged;
|
||||||
|
#elif UNITY_2020_1_OR_NEWER
|
||||||
|
_listView.onSelectionChange += OnSelectionChanged;
|
||||||
|
#else
|
||||||
|
_listView.onSelectionChanged += OnSelectionChanged;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 按钮组
|
||||||
|
var buttonContainer = new VisualElement();
|
||||||
|
buttonContainer.style.flexDirection = FlexDirection.RowReverse;
|
||||||
|
|
||||||
|
// 移除按钮
|
||||||
|
_removeButton = new Button();
|
||||||
|
_removeButton.text = " - ";
|
||||||
|
_removeButton.clicked += OnClickRemoveButton;
|
||||||
|
_removeButton.SetEnabled(false);
|
||||||
|
buttonContainer.Add(_removeButton);
|
||||||
|
|
||||||
|
// 增加按钮
|
||||||
|
_addButton = new Button();
|
||||||
|
_addButton.text = " + ";
|
||||||
|
_addButton.clicked += OnClickAddButton;
|
||||||
|
buttonContainer.Add(_addButton);
|
||||||
|
|
||||||
|
// 组织页面
|
||||||
|
if (foldout)
|
||||||
|
{
|
||||||
|
_foldout.Add(_listView);
|
||||||
|
_foldout.Add(buttonContainer);
|
||||||
|
this.Add(_foldout);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Add(_headerLabel);
|
||||||
|
this.Add(_listView);
|
||||||
|
this.Add(buttonContainer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnClickAddButton()
|
||||||
|
{
|
||||||
|
if (_listView.itemsSource != null)
|
||||||
|
{
|
||||||
|
object defaultValue = GetElementDefaultValue();
|
||||||
|
_listView.itemsSource.Add(defaultValue);
|
||||||
|
_listView.Rebuild();
|
||||||
|
RefreshFoldoutName();
|
||||||
|
RefreshRemoveButton();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("The source data is null !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnClickRemoveButton()
|
||||||
|
{
|
||||||
|
if (_listView.itemsSource != null)
|
||||||
|
{
|
||||||
|
if (_listView.selectedIndex >= 0)
|
||||||
|
{
|
||||||
|
_listView.itemsSource.RemoveAt(_listView.selectedIndex);
|
||||||
|
_listView.Rebuild();
|
||||||
|
RefreshFoldoutName();
|
||||||
|
RefreshRemoveButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("The source data is null !");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnSelectionChanged(IEnumerable<object> objs)
|
||||||
|
{
|
||||||
|
RefreshRemoveButton();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成元素
|
||||||
|
/// </summary>
|
||||||
|
private VisualElement MakeListViewElement()
|
||||||
|
{
|
||||||
|
if (MakeElementCallback != null)
|
||||||
|
{
|
||||||
|
return MakeElementCallback.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
Type elementType = GetElementType();
|
||||||
|
if (elementType == typeof(string))
|
||||||
|
{
|
||||||
|
TextField textField = new TextField();
|
||||||
|
textField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)textField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = textField.value;
|
||||||
|
});
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(int))
|
||||||
|
{
|
||||||
|
IntegerField intField = new IntegerField();
|
||||||
|
intField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)intField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = intField.value;
|
||||||
|
});
|
||||||
|
return intField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(long))
|
||||||
|
{
|
||||||
|
LongField longField = new LongField();
|
||||||
|
longField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)longField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = longField.value;
|
||||||
|
});
|
||||||
|
return longField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(float))
|
||||||
|
{
|
||||||
|
FloatField floatField = new FloatField();
|
||||||
|
floatField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)floatField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = floatField.value;
|
||||||
|
});
|
||||||
|
return floatField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(double))
|
||||||
|
{
|
||||||
|
DoubleField doubleField = new DoubleField();
|
||||||
|
doubleField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)doubleField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = doubleField.value;
|
||||||
|
});
|
||||||
|
return doubleField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(bool))
|
||||||
|
{
|
||||||
|
Toggle toggle = new Toggle();
|
||||||
|
toggle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)toggle.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = toggle.value;
|
||||||
|
});
|
||||||
|
return toggle;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Hash128))
|
||||||
|
{
|
||||||
|
Hash128Field hash128Field = new Hash128Field();
|
||||||
|
hash128Field.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)hash128Field.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = hash128Field.value;
|
||||||
|
});
|
||||||
|
return hash128Field;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector2))
|
||||||
|
{
|
||||||
|
Vector2Field vector2Field = new Vector2Field();
|
||||||
|
vector2Field.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)vector2Field.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = vector2Field.value;
|
||||||
|
});
|
||||||
|
return vector2Field;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector3))
|
||||||
|
{
|
||||||
|
Vector3Field vector3Field = new Vector3Field();
|
||||||
|
vector3Field.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)vector3Field.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = vector3Field.value;
|
||||||
|
});
|
||||||
|
return vector3Field;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector4))
|
||||||
|
{
|
||||||
|
Vector4Field vector4Field = new Vector4Field();
|
||||||
|
vector4Field.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)vector4Field.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = vector4Field.value;
|
||||||
|
});
|
||||||
|
return vector4Field;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Rect))
|
||||||
|
{
|
||||||
|
RectField rectField = new RectField();
|
||||||
|
rectField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)rectField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = rectField.value;
|
||||||
|
});
|
||||||
|
return rectField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Bounds))
|
||||||
|
{
|
||||||
|
BoundsField boundsField = new BoundsField();
|
||||||
|
boundsField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)boundsField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = boundsField.value;
|
||||||
|
});
|
||||||
|
return boundsField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Color))
|
||||||
|
{
|
||||||
|
ColorField colorField = new ColorField();
|
||||||
|
colorField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)colorField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = colorField.value;
|
||||||
|
});
|
||||||
|
return colorField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Gradient))
|
||||||
|
{
|
||||||
|
GradientField gradientField = new GradientField();
|
||||||
|
gradientField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)gradientField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = gradientField.value;
|
||||||
|
});
|
||||||
|
return gradientField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(AnimationCurve))
|
||||||
|
{
|
||||||
|
CurveField curveField = new CurveField();
|
||||||
|
curveField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)curveField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = curveField.value;
|
||||||
|
});
|
||||||
|
return curveField;
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(UnityEngine.Object))
|
||||||
|
{
|
||||||
|
ObjectField objectField = new ObjectField();
|
||||||
|
objectField.objectType = typeof(UnityEngine.Object);
|
||||||
|
objectField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)objectField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = objectField.value;
|
||||||
|
});
|
||||||
|
return objectField;
|
||||||
|
}
|
||||||
|
else if (elementType.IsEnum)
|
||||||
|
{
|
||||||
|
EnumField enumField = new EnumField();
|
||||||
|
enumField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
int itemIndex = (int)enumField.userData;
|
||||||
|
_listView.itemsSource[itemIndex] = enumField.value;
|
||||||
|
});
|
||||||
|
return enumField;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Label label = new Label();
|
||||||
|
label.text = $"Not support element type : {elementType.Name}";
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绑定元素
|
||||||
|
/// </summary>
|
||||||
|
private void BindListViewElement(VisualElement listViewElement, int index)
|
||||||
|
{
|
||||||
|
if (BindElementCallback != null)
|
||||||
|
{
|
||||||
|
BindElementCallback.Invoke(listViewElement, index);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var elementValue = _listView.itemsSource[index];
|
||||||
|
string elementName = GetElementName(index);
|
||||||
|
Type elementType = GetElementType();
|
||||||
|
if (elementType == typeof(string))
|
||||||
|
{
|
||||||
|
TextField textField = listViewElement as TextField;
|
||||||
|
textField.userData = index;
|
||||||
|
textField.label = elementName;
|
||||||
|
textField.SetValueWithoutNotify(elementValue as string);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(int))
|
||||||
|
{
|
||||||
|
IntegerField intField = listViewElement as IntegerField;
|
||||||
|
intField.userData = index;
|
||||||
|
intField.label = elementName;
|
||||||
|
intField.SetValueWithoutNotify((int)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(long))
|
||||||
|
{
|
||||||
|
LongField longField = listViewElement as LongField;
|
||||||
|
longField.userData = index;
|
||||||
|
longField.label = elementName;
|
||||||
|
longField.SetValueWithoutNotify((long)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(float))
|
||||||
|
{
|
||||||
|
FloatField floatField = listViewElement as FloatField;
|
||||||
|
floatField.userData = index;
|
||||||
|
floatField.label = elementName;
|
||||||
|
floatField.SetValueWithoutNotify((float)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(double))
|
||||||
|
{
|
||||||
|
DoubleField doubleField = listViewElement as DoubleField;
|
||||||
|
doubleField.userData = index;
|
||||||
|
doubleField.label = elementName;
|
||||||
|
doubleField.SetValueWithoutNotify((double)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(bool))
|
||||||
|
{
|
||||||
|
Toggle toggle = listViewElement as Toggle;
|
||||||
|
toggle.userData = index;
|
||||||
|
toggle.label = elementName;
|
||||||
|
toggle.SetValueWithoutNotify((bool)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Hash128))
|
||||||
|
{
|
||||||
|
Hash128Field hash128Field = listViewElement as Hash128Field;
|
||||||
|
hash128Field.userData = index;
|
||||||
|
hash128Field.label = elementName;
|
||||||
|
hash128Field.SetValueWithoutNotify((Hash128)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector2))
|
||||||
|
{
|
||||||
|
Vector2Field vector2Field = listViewElement as Vector2Field;
|
||||||
|
vector2Field.userData = index;
|
||||||
|
vector2Field.label = elementName;
|
||||||
|
vector2Field.SetValueWithoutNotify((Vector2)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector3))
|
||||||
|
{
|
||||||
|
Vector3Field vector3Field = listViewElement as Vector3Field;
|
||||||
|
vector3Field.userData = index;
|
||||||
|
vector3Field.label = elementName;
|
||||||
|
vector3Field.SetValueWithoutNotify((Vector3)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Vector4))
|
||||||
|
{
|
||||||
|
Vector4Field vector4Field = listViewElement as Vector4Field;
|
||||||
|
vector4Field.userData = index;
|
||||||
|
vector4Field.label = elementName;
|
||||||
|
vector4Field.SetValueWithoutNotify((Vector4)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Rect))
|
||||||
|
{
|
||||||
|
RectField rectField = listViewElement as RectField;
|
||||||
|
rectField.userData = index;
|
||||||
|
rectField.label = elementName;
|
||||||
|
rectField.SetValueWithoutNotify((Rect)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Bounds))
|
||||||
|
{
|
||||||
|
BoundsField boundsField = listViewElement as BoundsField;
|
||||||
|
boundsField.userData = index;
|
||||||
|
boundsField.label = elementName;
|
||||||
|
boundsField.SetValueWithoutNotify((Bounds)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Color))
|
||||||
|
{
|
||||||
|
ColorField colorField = listViewElement as ColorField;
|
||||||
|
colorField.userData = index;
|
||||||
|
colorField.label = elementName;
|
||||||
|
colorField.SetValueWithoutNotify((Color)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(Gradient))
|
||||||
|
{
|
||||||
|
GradientField gradientField = listViewElement as GradientField;
|
||||||
|
gradientField.userData = index;
|
||||||
|
gradientField.label = elementName;
|
||||||
|
gradientField.SetValueWithoutNotify((Gradient)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(AnimationCurve))
|
||||||
|
{
|
||||||
|
CurveField curveField = listViewElement as CurveField;
|
||||||
|
curveField.userData = index;
|
||||||
|
curveField.label = elementName;
|
||||||
|
curveField.SetValueWithoutNotify((AnimationCurve)elementValue);
|
||||||
|
}
|
||||||
|
else if (elementType == typeof(UnityEngine.Object))
|
||||||
|
{
|
||||||
|
ObjectField objectField = listViewElement as ObjectField;
|
||||||
|
objectField.userData = index;
|
||||||
|
objectField.label = elementName;
|
||||||
|
objectField.SetValueWithoutNotify(elementValue as UnityEngine.Object);
|
||||||
|
}
|
||||||
|
else if (elementType.IsEnum)
|
||||||
|
{
|
||||||
|
EnumField enumField = listViewElement as EnumField;
|
||||||
|
enumField.userData = index;
|
||||||
|
enumField.label = elementName;
|
||||||
|
enumField.Init((Enum)elementValue);
|
||||||
|
enumField.SetValueWithoutNotify((Enum)elementValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Type GetElementType()
|
||||||
|
{
|
||||||
|
Type elementType = _listView.itemsSource.GetType().GetGenericArguments()[0];
|
||||||
|
return elementType;
|
||||||
|
}
|
||||||
|
private object GetElementDefaultValue()
|
||||||
|
{
|
||||||
|
Type type = GetElementType();
|
||||||
|
if (type.IsValueType)
|
||||||
|
{
|
||||||
|
return Activator.CreateInstance(type);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
private string GetElementName(int index)
|
||||||
|
{
|
||||||
|
return $"Element {index}";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RefreshRemoveButton()
|
||||||
|
{
|
||||||
|
if (_listView.itemsSource == null)
|
||||||
|
{
|
||||||
|
_removeButton.SetEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:数据列表移除元素的时候有可能会越界!
|
||||||
|
if (_listView.selectedIndex >= _listView.itemsSource.Count)
|
||||||
|
_listView.ClearSelection();
|
||||||
|
|
||||||
|
if (_listView.selectedIndex >= 0)
|
||||||
|
_removeButton.SetEnabled(true);
|
||||||
|
else
|
||||||
|
_removeButton.SetEnabled(false);
|
||||||
|
}
|
||||||
|
private void RefreshFoldoutName()
|
||||||
|
{
|
||||||
|
if (_listView.itemsSource == null)
|
||||||
|
{
|
||||||
|
if (_foldout != null)
|
||||||
|
_foldout.text = _headerName;
|
||||||
|
if (_headerLabel != null)
|
||||||
|
_headerLabel.text = _headerName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_foldout != null)
|
||||||
|
_foldout.text = _headerName + $" ({_listView.itemsSource.Count}) ";
|
||||||
|
if (_headerLabel != null)
|
||||||
|
_headerLabel.text = _headerName + $" ({_listView.itemsSource.Count}) ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 111ec0d18888d7e4396b2192f7b4f347
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
108
Assets/YooAsset/Editor/UIElements/ElementsDefine/ResizeHandle.cs
Normal file
108
Assets/YooAsset/Editor/UIElements/ElementsDefine/ResizeHandle.cs
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ResizeHandle : VisualElement
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<ResizeHandle, UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool _isResizing = false;
|
||||||
|
private float _initialWidth;
|
||||||
|
private Vector2 _initialMousePos;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制的UI元素
|
||||||
|
/// </summary>
|
||||||
|
public VisualElement ControlTarget { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制元素的最小宽度
|
||||||
|
/// </summary>
|
||||||
|
public int ControlMinWidth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控制元素的最大宽度
|
||||||
|
/// </summary>
|
||||||
|
public int ControlMaxWidth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 尺寸发生变化
|
||||||
|
/// </summary>
|
||||||
|
public Action<float> ResizeChanged { get; set; }
|
||||||
|
|
||||||
|
public ResizeHandle()
|
||||||
|
{
|
||||||
|
int defaultWidth = 5;
|
||||||
|
this.style.width = defaultWidth;
|
||||||
|
this.style.minWidth = defaultWidth;
|
||||||
|
this.style.maxWidth = defaultWidth;
|
||||||
|
this.style.opacity = 0;
|
||||||
|
this.style.cursor = UIElementsCursor.CreateCursor(MouseCursor.ResizeHorizontal);
|
||||||
|
|
||||||
|
this.RegisterCallback<MouseDownEvent>(OnMouseDown);
|
||||||
|
this.RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
||||||
|
this.RegisterCallback<MouseUpEvent>(OnMouseUp);
|
||||||
|
}
|
||||||
|
public ResizeHandle(int handleWidth, VisualElement controlTarget, int controlMinWidth, int controlMaxWidth)
|
||||||
|
{
|
||||||
|
ControlTarget = controlTarget;
|
||||||
|
ControlMinWidth = controlMinWidth;
|
||||||
|
ControlMaxWidth = controlMaxWidth;
|
||||||
|
|
||||||
|
this.style.width = handleWidth;
|
||||||
|
this.style.minWidth = handleWidth;
|
||||||
|
this.style.maxWidth = handleWidth;
|
||||||
|
this.style.opacity = 0;
|
||||||
|
this.style.cursor = UIElementsCursor.CreateCursor(MouseCursor.ResizeHorizontal);
|
||||||
|
|
||||||
|
this.RegisterCallback<MouseDownEvent>(OnMouseDown);
|
||||||
|
this.RegisterCallback<MouseMoveEvent>(OnMouseMove);
|
||||||
|
this.RegisterCallback<MouseUpEvent>(OnMouseUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMouseDown(MouseDownEvent evt)
|
||||||
|
{
|
||||||
|
// 鼠标左键按下
|
||||||
|
if (ControlTarget != null && evt.button == 0)
|
||||||
|
{
|
||||||
|
_isResizing = true;
|
||||||
|
_initialWidth = ControlTarget.resolvedStyle.width;
|
||||||
|
_initialMousePos = evt.mousePosition;
|
||||||
|
this.CaptureMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnMouseMove(MouseMoveEvent evt)
|
||||||
|
{
|
||||||
|
if (ControlTarget != null && _isResizing)
|
||||||
|
{
|
||||||
|
// 计算鼠标移动距离
|
||||||
|
float deltaX = evt.mousePosition.x - _initialMousePos.x;
|
||||||
|
|
||||||
|
// 更新控制元素尺寸
|
||||||
|
float newWidth = _initialWidth + deltaX;
|
||||||
|
float width = Mathf.Clamp(newWidth, ControlMinWidth, ControlMaxWidth);
|
||||||
|
ControlTarget.style.width = width;
|
||||||
|
ControlTarget.style.minWidth = width;
|
||||||
|
ControlTarget.style.maxWidth = width;
|
||||||
|
ResizeChanged?.Invoke(width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnMouseUp(MouseUpEvent evt)
|
||||||
|
{
|
||||||
|
// 鼠标左键释放
|
||||||
|
if (ControlTarget != null && evt.button == 0)
|
||||||
|
{
|
||||||
|
_isResizing = false;
|
||||||
|
this.ReleaseMouse();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: adb565f9b5e9fb3428e54d0cfd58676d
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/YooAsset/Editor/UIElements/TableView.meta
Normal file
8
Assets/YooAsset/Editor/UIElements/TableView.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e5f8691a7e0c67d4ab790b703925cd75
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
64
Assets/YooAsset/Editor/UIElements/TableView/ColumnStyle.cs
Normal file
64
Assets/YooAsset/Editor/UIElements/TableView/ColumnStyle.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ColumnStyle
|
||||||
|
{
|
||||||
|
public const float MaxValue = 8388608f;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单元列宽度
|
||||||
|
/// </summary>
|
||||||
|
public Length Width;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单元列最小宽度
|
||||||
|
/// </summary>
|
||||||
|
public Length MinWidth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 单元列最大宽度
|
||||||
|
/// </summary>
|
||||||
|
public Length MaxWidth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可伸缩
|
||||||
|
/// </summary>
|
||||||
|
public bool Stretchable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可搜索
|
||||||
|
/// </summary>
|
||||||
|
public bool Searchable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 可排序
|
||||||
|
/// </summary>
|
||||||
|
public bool Sortable = false;
|
||||||
|
|
||||||
|
public ColumnStyle(Length width)
|
||||||
|
{
|
||||||
|
if (width.value > MaxValue)
|
||||||
|
width = MaxValue;
|
||||||
|
|
||||||
|
Width = width;
|
||||||
|
MinWidth = width;
|
||||||
|
MaxWidth = width;
|
||||||
|
}
|
||||||
|
public ColumnStyle(Length width, Length minWidth, Length maxWidth)
|
||||||
|
{
|
||||||
|
if (maxWidth.value > MaxValue)
|
||||||
|
maxWidth = MaxValue;
|
||||||
|
|
||||||
|
Width = width;
|
||||||
|
MinWidth = minWidth;
|
||||||
|
MaxWidth = maxWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6a74bbcb5d814f94fb54042ec3b6d94c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8b25809b75e1e7141aff3c2011845aab
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetPathCell : StringValueCell
|
||||||
|
{
|
||||||
|
public AssetPathCell(string searchTag, object cellValue) : base(searchTag, cellValue)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检视资源对象
|
||||||
|
/// Ping an asset object in the Scene like clicking it in an inspector.
|
||||||
|
/// </summary>
|
||||||
|
public bool PingAssetObject()
|
||||||
|
{
|
||||||
|
var assetPath = StringValue;
|
||||||
|
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
UnityEngine.Object asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(assetPath);
|
||||||
|
if (asset == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Selection.activeObject = asset;
|
||||||
|
EditorGUIUtility.PingObject(asset);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ed1c077653e577846ba29aadb91f13ec
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class BooleanValueCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
public bool BooleanValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (bool)CellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BooleanValueCell(string searchTag, object cellValue)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
CellValue = cellValue;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return CellValue.ToString();
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
if (other is BooleanValueCell cell)
|
||||||
|
{
|
||||||
|
return this.BooleanValue.CompareTo(cell.BooleanValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f7b1e743b81646b49b2c05721edcf9b4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ButtonCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
|
||||||
|
public ButtonCell(string searchTag)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fe6c2551d70d6934da0b6afce3f1062c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class IntegerValueCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
public long IntegerValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (long)CellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntegerValueCell(string searchTag, object cellValue)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
CellValue = cellValue;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return CellValue.ToString();
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
if (other is IntegerValueCell cell)
|
||||||
|
{
|
||||||
|
return this.IntegerValue.CompareTo(cell.IntegerValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: be8ecb3981efa744f89ee5d3c9e7b7ad
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class SingleValueCell : ITableCell, IComparable
|
||||||
|
{
|
||||||
|
public object CellValue { set; get; }
|
||||||
|
public string SearchTag { private set; get; }
|
||||||
|
public double SingleValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (double)CellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleValueCell(string searchTag, object cellValue)
|
||||||
|
{
|
||||||
|
SearchTag = searchTag;
|
||||||
|
CellValue = cellValue;
|
||||||
|
}
|
||||||
|
public object GetDisplayObject()
|
||||||
|
{
|
||||||
|
return CellValue.ToString();
|
||||||
|
}
|
||||||
|
public int CompareTo(object other)
|
||||||
|
{
|
||||||
|
if (other is SingleValueCell cell)
|
||||||
|
{
|
||||||
|
return this.SingleValue.CompareTo(cell.SingleValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ae299b7a930e03f458977750de9ca18e
|
||||||
|
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
Reference in New Issue
Block a user