【m】框架大更新
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ReporterAssetListViewer
|
||||
{
|
||||
private class AssetTableData : DefaultTableData
|
||||
{
|
||||
public ReportAssetInfo AssetInfo;
|
||||
}
|
||||
private class DependTableData : DefaultTableData
|
||||
{
|
||||
public ReportBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private TableViewer _assetTableView;
|
||||
private TableViewer _dependTableView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterAssetListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetTableView = _root.Q<TableViewer>("TopTableView");
|
||||
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
|
||||
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
|
||||
CreateAssetTableViewColumns();
|
||||
|
||||
// 依赖列表
|
||||
_dependTableView = _root.Q<TableViewer>("BottomTableView");
|
||||
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||
CreateDependTableViewColumns();
|
||||
|
||||
// 面板分屏
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
}
|
||||
private void CreateAssetTableViewColumns()
|
||||
{
|
||||
// AssetPath
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_assetTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//MainBundle
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("MainBundle", "Main Bundle", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_assetTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateDependTableViewColumns()
|
||||
{
|
||||
// DependBundles
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileSize
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("FileSize", "File Size", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
long fileSize = (long)cell.CellValue;
|
||||
infoLabel.text = EditorUtility.FormatBytes(fileSize);
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileHash
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("FileHash", "File Hash", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
|
||||
// 清空旧数据
|
||||
_assetTableView.ClearAll(false, true);
|
||||
_dependTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_buildReport.AssetInfos.Count);
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
var rowData = new AssetTableData();
|
||||
rowData.AssetInfo = assetInfo;
|
||||
rowData.AddAssetPathCell("AssetPath", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("MainBundle", assetInfo.MainBundleName);
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
_assetTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
// 重建视图
|
||||
_assetTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
private void OnAssetTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
var assetTableData = data as AssetTableData;
|
||||
ReportAssetInfo assetInfo = assetTableData.AssetInfo;
|
||||
|
||||
// 填充依赖数据
|
||||
var sourceDatas = new List<ITableData>(assetInfo.DependBundles.Count);
|
||||
foreach (string dependBundleName in assetInfo.DependBundles)
|
||||
{
|
||||
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
||||
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;
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
private void OnClickAssetTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
foreach (var cell in data.Cells)
|
||||
{
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
var dependTableData = data as DependTableData;
|
||||
if (dependTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{dependTableData.BundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddce16c5ebbb73d4fa11b3d9b6cd7f6a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e077c5b54be900644882d0ce03df9f75
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,378 @@
|
||||
#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
|
||||
{
|
||||
internal class ReporterBundleListViewer
|
||||
{
|
||||
private class BundleTableData : DefaultTableData
|
||||
{
|
||||
public ReportBundleInfo BundleInfo;
|
||||
}
|
||||
private class IncludeTableData : DefaultTableData
|
||||
{
|
||||
public ReportAssetInfo AssetInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private TableViewer _bundleTableView;
|
||||
private TableViewer _includeTableView;
|
||||
|
||||
private BuildReport _buildReport;
|
||||
private string _reportFilePath;
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterBundleListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleTableView = _root.Q<TableViewer>("TopTableView");
|
||||
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||
CreateBundleTableViewColumns();
|
||||
|
||||
// 包含列表
|
||||
_includeTableView = _root.Q<TableViewer>("BottomTableView");
|
||||
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
|
||||
CreateIncludeTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||
topGroup.style.minHeight = 100;
|
||||
bottomGroup.style.minHeight = 100f;
|
||||
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||
#endif
|
||||
}
|
||||
private void CreateBundleTableViewColumns()
|
||||
{
|
||||
//BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileSize
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("FileSize", "File Size", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
long fileSize = (long)cell.CellValue;
|
||||
infoLabel.text = EditorUtility.FormatBytes(fileSize);
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// FileHash
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("FileHash", "File Hash", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//Encrypted
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Encrypted", "Encrypted", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
bool encrypted = (bool)cell.CellValue;
|
||||
infoLabel.text = encrypted.ToString();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//Tags
|
||||
{
|
||||
var columnStyle = new ColumnStyle(150, 100, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Tags", "Tags", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateIncludeTableViewColumns()
|
||||
{
|
||||
//IncludeAssets
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("IncludeAssets", "Include Assets", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//AssetSource
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("AssetSource", "Asset Source", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
//AssetGUID
|
||||
{
|
||||
var columnStyle = new ColumnStyle(250);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("AssetGUID", "Asset GUID", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_includeTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport, string reprotFilePath)
|
||||
{
|
||||
_buildReport = buildReport;
|
||||
_reportFilePath = reprotFilePath;
|
||||
|
||||
// 清空旧数据
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_includeTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_buildReport.BundleInfos.Count);
|
||||
foreach (var bundleInfo in _buildReport.BundleInfos)
|
||||
{
|
||||
var rowData = new BundleTableData();
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("FileSize", bundleInfo.FileSize);
|
||||
rowData.AddStringValueCell("FileHash", bundleInfo.FileHash);
|
||||
rowData.AddBoolValueCell("Encrypted", bundleInfo.Encrypted);
|
||||
rowData.AddStringValueCell("Tags", string.Join(";", bundleInfo.Tags));
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
_bundleTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
// 重建视图
|
||||
_bundleTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
var bundleTableData = data as BundleTableData;
|
||||
var bundleInfo = bundleTableData.BundleInfo;
|
||||
|
||||
// 填充包含数据
|
||||
var sourceDatas = new List<ITableData>();
|
||||
var mainAssetDic = new HashSet<string>();
|
||||
foreach (var assetInfo in _buildReport.AssetInfos)
|
||||
{
|
||||
if (assetInfo.MainBundleName == bundleInfo.BundleName)
|
||||
{
|
||||
mainAssetDic.Add(assetInfo.AssetPath);
|
||||
|
||||
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 (var assetInfo in bundleInfo.BundleContents)
|
||||
{
|
||||
if (mainAssetDic.Contains(assetInfo.AssetPath) == false)
|
||||
{
|
||||
var rowData = new IncludeTableData();
|
||||
rowData.AssetInfo = null;
|
||||
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
|
||||
rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
|
||||
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
|
||||
_includeTableView.itemsSource = sourceDatas;
|
||||
_includeTableView.RebuildView();
|
||||
}
|
||||
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
var bundleTableData = data as BundleTableData;
|
||||
if (bundleTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
{
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{bundleTableData.BundleInfo.FileName}";
|
||||
if (File.Exists(filePath))
|
||||
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
|
||||
else
|
||||
Selection.activeObject = null;
|
||||
}
|
||||
}
|
||||
private void OnClickIncludeTableView(PointerDownEvent evt, ITableData data)
|
||||
{
|
||||
// 鼠标双击后检视
|
||||
if (evt.clickCount != 2)
|
||||
return;
|
||||
|
||||
foreach (var cell in data.Cells)
|
||||
{
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a8ecbacce158fc4d9d4d87b7c44b42d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93f6f95d85a14e545a75b0335085339d
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -0,0 +1,180 @@
|
||||
#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
|
||||
{
|
||||
internal class ReporterSummaryViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
private ScrollView _scrollView;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterSummaryViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 概述列表
|
||||
_scrollView = _root.Q<ScrollView>("ScrollView");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(BuildReport buildReport)
|
||||
{
|
||||
_scrollView.Clear();
|
||||
|
||||
BindListViewHeader("Build Infos");
|
||||
BindListViewItem("YooAsset Version", buildReport.Summary.YooVersion);
|
||||
BindListViewItem("UnityEngine Version", buildReport.Summary.UnityVersion);
|
||||
BindListViewItem("Build Date", buildReport.Summary.BuildDate);
|
||||
BindListViewItem("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds));
|
||||
BindListViewItem("Build Target", $"{buildReport.Summary.BuildTarget}");
|
||||
BindListViewItem("Build Pipeline", $"{buildReport.Summary.BuildPipeline}");
|
||||
BindListViewItem("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString());
|
||||
BindListViewItem("Package Name", buildReport.Summary.BuildPackageName);
|
||||
BindListViewItem("Package Version", buildReport.Summary.BuildPackageVersion);
|
||||
BindListViewItem("Package Note", buildReport.Summary.BuildPackageNote);
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
BindListViewHeader("Collect Settings");
|
||||
BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
|
||||
BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
|
||||
BindListViewItem("Support Extensionless", $"{buildReport.Summary.SupportExtensionless}");
|
||||
BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
|
||||
BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
|
||||
BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
|
||||
BindListViewItem("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}");
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
BindListViewHeader("Build Params");
|
||||
BindListViewItem("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}");
|
||||
BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
|
||||
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
|
||||
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
|
||||
BindListViewItem("Encryption Services", buildReport.Summary.EncryptionServicesClassName);
|
||||
BindListViewItem("Manifest Process Services", buildReport.Summary.ManifestProcessServicesClassName);
|
||||
BindListViewItem("Manifest Restore Services", buildReport.Summary.ManifestRestoreServicesClassName);
|
||||
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
|
||||
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
||||
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
||||
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
|
||||
BindListViewItem(string.Empty, string.Empty);
|
||||
|
||||
BindListViewHeader("Build Results");
|
||||
BindListViewItem("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}");
|
||||
BindListViewItem("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}");
|
||||
BindListViewItem("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}");
|
||||
BindListViewItem("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize));
|
||||
BindListViewItem("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}");
|
||||
BindListViewItem("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
// 列表相关
|
||||
private void BindListViewHeader(string titile)
|
||||
{
|
||||
Toolbar toolbar = new Toolbar();
|
||||
_scrollView.Add(toolbar);
|
||||
|
||||
ToolbarButton titleButton = new ToolbarButton();
|
||||
titleButton.text = titile;
|
||||
titleButton.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
titleButton.style.width = 200;
|
||||
toolbar.Add(titleButton);
|
||||
|
||||
ToolbarButton valueButton = new ToolbarButton();
|
||||
valueButton.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
valueButton.style.width = 150;
|
||||
valueButton.style.flexShrink = 1;
|
||||
valueButton.style.flexGrow = 1;
|
||||
valueButton.SetEnabled(false);
|
||||
toolbar.Add(valueButton);
|
||||
}
|
||||
private void BindListViewItem(string name, string value)
|
||||
{
|
||||
VisualElement element = MakeListViewItem();
|
||||
_scrollView.Add(element);
|
||||
|
||||
// Title
|
||||
var titleLabel = element.Q<Label>("TitleLabel");
|
||||
titleLabel.text = name;
|
||||
|
||||
// Value
|
||||
var valueLabel = element.Q<Label>("ValueLabel");
|
||||
valueLabel.text = value;
|
||||
}
|
||||
private VisualElement MakeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
var titleLabel = new Label();
|
||||
titleLabel.name = "TitleLabel";
|
||||
titleLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
titleLabel.style.marginLeft = 3f;
|
||||
titleLabel.style.width = 200;
|
||||
element.Add(titleLabel);
|
||||
|
||||
var valueLabel = new Label();
|
||||
valueLabel.name = "ValueLabel";
|
||||
valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
valueLabel.style.marginLeft = 3f;
|
||||
valueLabel.style.flexGrow = 1f;
|
||||
valueLabel.style.width = 150;
|
||||
element.Add(valueLabel);
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
private string ConvertTime(int time)
|
||||
{
|
||||
if (time <= 60)
|
||||
{
|
||||
return $"{time}秒钟";
|
||||
}
|
||||
else
|
||||
{
|
||||
int minute = time / 60;
|
||||
return $"{minute}分钟";
|
||||
}
|
||||
}
|
||||
private string ConvertSize(long size)
|
||||
{
|
||||
if (size == 0)
|
||||
return "0";
|
||||
return EditorUtility.FormatBytes(size);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 896c12501e8f07d47ad8b7362529ab56
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,5 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<ui:ScrollView name="ScrollView" horizontal-scroller-visibility="Hidden" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac015612956bc8544862fdd3803491bb
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
Reference in New Issue
Block a user