mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-14 16:51:28 +00:00
TEngine 6
This commit is contained in:
@@ -11,12 +11,24 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerAssetListViewer
|
||||
{
|
||||
private class ProviderTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class DependTableData : DefaultTableData
|
||||
{
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private DebugReport _debugReport;
|
||||
private TableViewer _providerTableView;
|
||||
private TableViewer _dependTableView;
|
||||
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@@ -32,23 +44,287 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
_providerTableView = _root.Q<TableViewer>("TopTableView");
|
||||
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
|
||||
CreateAssetTableViewColumns();
|
||||
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
_dependTableView = _root.Q<TableViewer>("BottomTableView");
|
||||
CreateDependTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
#endif
|
||||
// 面板分屏
|
||||
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()
|
||||
{
|
||||
// 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;
|
||||
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();
|
||||
};
|
||||
_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);
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("BeginTime", "Begin 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(130);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Units = "ms";
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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.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;
|
||||
};
|
||||
_dependTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport)
|
||||
{
|
||||
// 清空旧数据
|
||||
_providerTableView.ClearAll(false, true);
|
||||
_dependTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
var rowData = new ProviderTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||
rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
|
||||
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>
|
||||
@@ -56,46 +332,25 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource.Clear();
|
||||
_assetListView.Rebuild();
|
||||
_providerTableView.ClearAll(false, true);
|
||||
_providerTableView.RebuildView();
|
||||
|
||||
_dependTableView.ClearAll(false, true);
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_assetListView.Clear();
|
||||
_assetListView.ClearSelection();
|
||||
_assetListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_assetListView.Rebuild();
|
||||
}
|
||||
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
// 搜索匹配
|
||||
if (_sourceDatas != null)
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
providerInfo.PackageName = packageData.PackageName;
|
||||
tempList.Add(providerInfo);
|
||||
}
|
||||
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
// 重建视图
|
||||
_providerTableView.RebuildView();
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -114,194 +369,26 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
private void OnProviderTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var providerTableData = data as ProviderTableData;
|
||||
DebugPackageData packageData = providerTableData.PackageData;
|
||||
DebugProviderInfo providerInfo = providerTableData.ProviderInfo;
|
||||
|
||||
// 填充依赖数据
|
||||
var sourceDatas = new List<ITableData>(providerInfo.DependBundles.Count);
|
||||
foreach (var bundleName in providerInfo.DependBundles)
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
var dependBundleInfo = packageData.GetBundleInfo(bundleName);
|
||||
var rowData = new DependTableData();
|
||||
rowData.BundleInfo = dependBundleInfo;
|
||||
rowData.AddStringValueCell("DependBundles", dependBundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", dependBundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", dependBundleInfo.Status.ToString());
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label6";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<DebugProviderInfo>;
|
||||
var providerInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = providerInfo.PackageName;
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Loading Time
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.LoadingTime.ToString();
|
||||
|
||||
// Ref Count
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (providerInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label6 = element.Q<Label>("Label6");
|
||||
label6.text = providerInfo.Status.ToString();
|
||||
label6.style.color = textColor;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugProviderInfo providerInfo = item as DebugProviderInfo;
|
||||
FillDependListView(providerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugBundleInfo> bundles = _dependListView.itemsSource as List<DebugBundleInfo>;
|
||||
DebugBundleInfo bundleInfo = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
}
|
||||
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
|
||||
{
|
||||
_dependListView.Clear();
|
||||
_dependListView.ClearSelection();
|
||||
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
|
||||
_dependListView.Rebuild();
|
||||
_dependTableView.itemsSource = sourceDatas;
|
||||
_dependTableView.RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,22 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="TopBar3" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Loading Time (ms)" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar5" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar6" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||
<YooAsset.Editor.TableViewer name="BottomTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@@ -11,12 +11,28 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal class DebuggerBundleListViewer
|
||||
{
|
||||
private class BundleTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
private class UsingTableData : DefaultTableData
|
||||
{
|
||||
public DebugProviderInfo ProviderInfo;
|
||||
}
|
||||
private class ReferenceTableData : DefaultTableData
|
||||
{
|
||||
public DebugBundleInfo BundleInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _bundleListView;
|
||||
private ListView _usingListView;
|
||||
private DebugReport _debugReport;
|
||||
private TableViewer _bundleTableView;
|
||||
private TableViewer _usingTableView;
|
||||
private TableViewer _referenceTableView;
|
||||
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
@@ -32,23 +48,342 @@ namespace YooAsset.Editor
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
_bundleTableView = _root.Q<TableViewer>("BundleTableView");
|
||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||
CreateBundleTableViewColumns();
|
||||
|
||||
// 使用列表
|
||||
_usingListView = _root.Q<ListView>("BottomListView");
|
||||
_usingListView.makeItem = MakeIncludeListViewItem;
|
||||
_usingListView.bindItem = BindIncludeListViewItem;
|
||||
_usingTableView = _root.Q<TableViewer>("UsingTableView");
|
||||
CreateUsingTableViewColumns();
|
||||
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
SplitView.Adjuster(_root);
|
||||
#endif
|
||||
// 引用列表
|
||||
_referenceTableView = _root.Q<TableViewer>("ReferenceTableView");
|
||||
CreateReferenceTableViewColumns();
|
||||
|
||||
// 面板分屏
|
||||
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);
|
||||
UIElementsTools.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
||||
}
|
||||
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;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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.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;
|
||||
};
|
||||
_bundleTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateUsingTableViewColumns()
|
||||
{
|
||||
// UsingAssets
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = 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);
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var usingTableData = data as UsingTableData;
|
||||
if (usingTableData.ProviderInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
infoLabel.style.color = textColor;
|
||||
};
|
||||
_usingTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateReferenceTableViewColumns()
|
||||
{
|
||||
// BundleName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(600, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// RefCount
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("RefCount", "Ref Count", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Status", "Status", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
StyleColor textColor;
|
||||
var feferenceTableData = data as ReferenceTableData;
|
||||
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed.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;
|
||||
};
|
||||
_referenceTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport)
|
||||
{
|
||||
// 清空旧数据
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
foreach (var bundleInfo in packageData.BundleInfos)
|
||||
{
|
||||
var rowData = new BundleTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
_bundleTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -56,53 +391,29 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_debugReport = null;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource.Clear();
|
||||
_bundleListView.Rebuild();
|
||||
_bundleTableView.ClearAll(false, true);
|
||||
_bundleTableView.RebuildView();
|
||||
|
||||
_usingTableView.ClearAll(false, true);
|
||||
_usingTableView.RebuildView();
|
||||
|
||||
_referenceTableView.ClearAll(false, true);
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport, string searchKeyWord)
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
_debugReport = debugReport;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.ClearSelection();
|
||||
_bundleListView.itemsSource = FilterViewItems(debugReport, searchKeyWord);
|
||||
_bundleListView.Rebuild();
|
||||
}
|
||||
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
|
||||
{
|
||||
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
|
||||
foreach (var pakcageData in debugReport.PackageDatas)
|
||||
{
|
||||
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
|
||||
foreach (var providerInfo in pakcageData.ProviderInfos)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
// 搜索匹配
|
||||
if(_sourceDatas != null)
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
|
||||
{
|
||||
bundleInfo.PackageName = pakcageData.PackageName;
|
||||
tempDic.Add(bundleInfo.BundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var tempList = tempDic.Values.ToList();
|
||||
tempList.Sort();
|
||||
result.AddRange(tempList);
|
||||
}
|
||||
return result;
|
||||
// 重建视图
|
||||
_bundleTableView.RebuildView();
|
||||
_usingTableView.RebuildView();
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -121,199 +432,53 @@ namespace YooAsset.Editor
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 顶部列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
private void OnBundleTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
var bundleTableData = data as BundleTableData;
|
||||
var packageData = bundleTableData.PackageData;
|
||||
var selectBundleInfo = bundleTableData.BundleInfo;
|
||||
|
||||
// 填充UsingTableView
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label0";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<DebugBundleInfo>;
|
||||
var bundleInfo = sourceData[index];
|
||||
|
||||
// Package Name
|
||||
var label0 = element.Q<Label>("Label0");
|
||||
label0.text = bundleInfo.PackageName;
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = bundleInfo.BundleName;
|
||||
|
||||
// Ref Count
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = bundleInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
StyleColor textColor;
|
||||
if (bundleInfo.Status == BundleLoaderBase.EStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = label1.style.color;
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = bundleInfo.Status.ToString();
|
||||
label4.style.color = textColor;
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
|
||||
FillUsingListView(bundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
// 底部列表相关
|
||||
private VisualElement MakeIncludeListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 150;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 120;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindIncludeListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<DebugProviderInfo> providers = _usingListView.itemsSource as List<DebugProviderInfo>;
|
||||
DebugProviderInfo providerInfo = providers[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = providerInfo.AssetPath;
|
||||
|
||||
// Spawn Scene
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = providerInfo.SpawnScene;
|
||||
|
||||
// Spawn Time
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = providerInfo.SpawnTime;
|
||||
|
||||
// Ref Count
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = providerInfo.RefCount.ToString();
|
||||
|
||||
// Status
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = providerInfo.Status.ToString();
|
||||
}
|
||||
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
|
||||
{
|
||||
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
|
||||
foreach (var packageData in _debugReport.PackageDatas)
|
||||
{
|
||||
if (packageData.PackageName == selectedBundleInfo.PackageName)
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
{
|
||||
foreach (var providerInfo in packageData.ProviderInfos)
|
||||
foreach (var dependBundleName in providerInfo.DependBundles)
|
||||
{
|
||||
foreach (var bundleInfo in providerInfo.DependBundleInfos)
|
||||
if (dependBundleName == selectBundleInfo.BundleName)
|
||||
{
|
||||
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
|
||||
{
|
||||
source.Add(providerInfo);
|
||||
continue;
|
||||
}
|
||||
var rowData = new UsingTableData();
|
||||
rowData.ProviderInfo = providerInfo;
|
||||
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
|
||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||
rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
|
||||
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", providerInfo.Status);
|
||||
sourceDatas.Add(rowData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
_usingTableView.itemsSource = sourceDatas;
|
||||
_usingTableView.RebuildView();
|
||||
}
|
||||
|
||||
_usingListView.Clear();
|
||||
_usingListView.ClearSelection();
|
||||
_usingListView.itemsSource = source;
|
||||
_usingListView.Rebuild();
|
||||
// 填充ReferenceTableView
|
||||
{
|
||||
var sourceDatas = new List<ITableData>(1000);
|
||||
foreach (string referenceBundleName in selectBundleInfo.ReferenceBundles)
|
||||
{
|
||||
var bundleInfo = packageData.GetBundleInfo(referenceBundleName);
|
||||
var rowData = new ReferenceTableData();
|
||||
rowData.BundleInfo = bundleInfo;
|
||||
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
|
||||
rowData.AddLongValueCell("RefCount", bundleInfo.RefCount);
|
||||
rowData.AddStringValueCell("Status", bundleInfo.Status.ToString());
|
||||
sourceDatas.Add(rowData);
|
||||
}
|
||||
_referenceTableView.itemsSource = sourceDatas;
|
||||
_referenceTableView.RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,9 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Package Name" display-tooltip-when-elided="true" name="TopBar0" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="TopBar3" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="TopBar4" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<YooAsset.Editor.TableViewer name="BundleTableView" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Using Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Spawn Scene" display-tooltip-when-elided="true" name="BottomBar2" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Spawn Time" display-tooltip-when-elided="true" name="BottomBar3" style="width: 150px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Ref Count" display-tooltip-when-elided="true" name="BottomBar4" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Status" display-tooltip-when-elided="true" name="BottomBar5" style="width: 120px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="BottomGroup" style="height: 400px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableViewer name="UsingTableView" />
|
||||
<YooAsset.Editor.TableViewer name="ReferenceTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
@@ -0,0 +1,509 @@
|
||||
#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 DebuggerOperationListViewer
|
||||
{
|
||||
private class OperationTableData : DefaultTableData
|
||||
{
|
||||
public DebugPackageData PackageData;
|
||||
public DebugOperationInfo OperationInfo;
|
||||
}
|
||||
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private TableViewer _operationTableView;
|
||||
private Toolbar _bottomToolbar;
|
||||
private TreeViewer _childTreeView;
|
||||
|
||||
private List<ITableData> _sourceDatas;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerOperationListViewer>();
|
||||
if (_visualAsset == null)
|
||||
return;
|
||||
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 任务列表
|
||||
_operationTableView = _root.Q<TableViewer>("TopTableView");
|
||||
_operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged;
|
||||
CreateOperationTableViewColumns();
|
||||
|
||||
// 底部标题栏
|
||||
_bottomToolbar = _root.Q<Toolbar>("BottomToolbar");
|
||||
CreateBottomToolbarHeaders();
|
||||
|
||||
// 子列表
|
||||
_childTreeView = _root.Q<TreeViewer>("BottomTreeView");
|
||||
_childTreeView.makeItem = MakeTreeViewItem;
|
||||
_childTreeView.bindItem = BindTreeViewItem;
|
||||
|
||||
// 面板分屏
|
||||
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 CreateOperationTableViewColumns()
|
||||
{
|
||||
// PackageName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(200);
|
||||
columnStyle.Searchable = true;
|
||||
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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// OperationName
|
||||
{
|
||||
var columnStyle = new ColumnStyle(300, 300, 600);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Counter = true;
|
||||
var column = new TableColumn("OperationName", "Operation 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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Priority
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("Priority", "Priority", 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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Progress
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("Progress", "Progress", 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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(100);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("BeginTime", "Begin 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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// ProcessTime
|
||||
{
|
||||
var columnStyle = new ColumnStyle(130);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
columnStyle.Units = "ms";
|
||||
var column = new TableColumn("ProcessTime", "Process 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();
|
||||
};
|
||||
_operationTableView.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 operationTableData = data as OperationTableData;
|
||||
if (operationTableData.OperationInfo.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;
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// Desc
|
||||
{
|
||||
var columnStyle = new ColumnStyle(500, 500, 1000);
|
||||
columnStyle.Stretchable = true;
|
||||
columnStyle.Searchable = true;
|
||||
var column = new TableColumn("Desc", "Desc", 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();
|
||||
};
|
||||
_operationTableView.AddColumn(column);
|
||||
}
|
||||
}
|
||||
private void CreateBottomToolbarHeaders()
|
||||
{
|
||||
// OperationName
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "OperationName";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 315;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
|
||||
// Progress
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "Progress";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 100;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "BeginTime";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 100;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
|
||||
// ProcessTime
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "ProcessTime (ms)";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 130;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "Status";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 100;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
|
||||
// Desc
|
||||
{
|
||||
ToolbarButton button = new ToolbarButton();
|
||||
button.text = "Desc";
|
||||
button.style.flexGrow = 0;
|
||||
button.style.width = 500;
|
||||
_bottomToolbar.Add(button);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(DebugReport debugReport)
|
||||
{
|
||||
// 清空旧数据
|
||||
_operationTableView.ClearAll(false, true);
|
||||
_childTreeView.ClearAll();
|
||||
_childTreeView.RebuildView();
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(1000);
|
||||
foreach (var packageData in debugReport.PackageDatas)
|
||||
{
|
||||
foreach (var operationInfo in packageData.OperationInfos)
|
||||
{
|
||||
var rowData = new OperationTableData();
|
||||
rowData.PackageData = packageData;
|
||||
rowData.OperationInfo = operationInfo;
|
||||
rowData.AddStringValueCell("PackageName", packageData.PackageName);
|
||||
rowData.AddStringValueCell("OperationName", operationInfo.OperationName);
|
||||
rowData.AddLongValueCell("Priority", operationInfo.Priority);
|
||||
rowData.AddDoubleValueCell("Progress", operationInfo.Progress);
|
||||
rowData.AddStringValueCell("BeginTime", operationInfo.BeginTime);
|
||||
rowData.AddLongValueCell("LoadingTime", operationInfo.ProcessTime);
|
||||
rowData.AddStringValueCell("Status", operationInfo.Status.ToString());
|
||||
rowData.AddStringValueCell("Desc", operationInfo.OperationDesc);
|
||||
_sourceDatas.Add(rowData);
|
||||
}
|
||||
}
|
||||
_operationTableView.itemsSource = _sourceDatas;
|
||||
|
||||
// 重建视图
|
||||
RebuildView(null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空页面
|
||||
/// </summary>
|
||||
public void ClearView()
|
||||
{
|
||||
_operationTableView.ClearAll(false, true);
|
||||
_operationTableView.RebuildView();
|
||||
|
||||
_childTreeView.ClearAll();
|
||||
_childTreeView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重建视图
|
||||
/// </summary>
|
||||
public void RebuildView(string searchKeyWord)
|
||||
{
|
||||
// 搜索匹配
|
||||
if(_sourceDatas != null)
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||
|
||||
// 重建视图
|
||||
_operationTableView.RebuildView();
|
||||
_childTreeView.RebuildView();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
private void OnOperationTableViewSelectionChanged(ITableData data)
|
||||
{
|
||||
var operationTableData = data as OperationTableData;
|
||||
DebugPackageData packageData = operationTableData.PackageData;
|
||||
DebugOperationInfo operationInfo = operationTableData.OperationInfo;
|
||||
|
||||
TreeNode rootNode = new TreeNode(operationInfo);
|
||||
FillTreeData(operationInfo, rootNode);
|
||||
_childTreeView.ClearAll();
|
||||
_childTreeView.SetRootItem(rootNode);
|
||||
_childTreeView.RebuildView();
|
||||
}
|
||||
private void MakeTreeViewItem(VisualElement container)
|
||||
{
|
||||
// OperationName
|
||||
{
|
||||
Label label = new Label();
|
||||
label.name = "OperationName";
|
||||
label.style.flexGrow = 0f;
|
||||
label.style.width = 300;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
|
||||
// Progress
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Progress";
|
||||
label.style.flexGrow = 0f;
|
||||
label.style.width = 100;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "BeginTime";
|
||||
label.style.flexGrow = 0f;
|
||||
label.style.width = 100;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
|
||||
// ProcessTime
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "ProcessTime";
|
||||
label.style.flexGrow = 0f;
|
||||
label.style.width = 130;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Status";
|
||||
label.style.flexGrow = 0f;
|
||||
label.style.width = 100;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
|
||||
// Desc
|
||||
{
|
||||
Label label = new Label();
|
||||
label.name = "Desc";
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 500;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
container.Add(label);
|
||||
}
|
||||
}
|
||||
private void BindTreeViewItem(VisualElement container, object userData)
|
||||
{
|
||||
var operationInfo = (DebugOperationInfo)userData;
|
||||
|
||||
// OperationName
|
||||
{
|
||||
var label = container.Q<Label>("OperationName");
|
||||
label.text = operationInfo.OperationName;
|
||||
}
|
||||
|
||||
// Progress
|
||||
{
|
||||
var label = container.Q<Label>("Progress");
|
||||
label.text = operationInfo.Progress.ToString();
|
||||
}
|
||||
|
||||
// BeginTime
|
||||
{
|
||||
var label = container.Q<Label>("BeginTime");
|
||||
label.text = operationInfo.BeginTime;
|
||||
}
|
||||
|
||||
// ProcessTime
|
||||
{
|
||||
var label = container.Q<Label>("ProcessTime");
|
||||
label.text = operationInfo.ProcessTime.ToString();
|
||||
}
|
||||
|
||||
// Status
|
||||
{
|
||||
StyleColor textColor;
|
||||
if (operationInfo.Status == EOperationStatus.Failed.ToString())
|
||||
textColor = new StyleColor(Color.yellow);
|
||||
else
|
||||
textColor = new StyleColor(Color.white);
|
||||
|
||||
var label = container.Q<Label>("Status");
|
||||
label.text = operationInfo.Status;
|
||||
label.style.color = textColor;
|
||||
}
|
||||
|
||||
// Desc
|
||||
{
|
||||
var label = container.Q<Label>("Desc");
|
||||
label.text = operationInfo.OperationDesc;
|
||||
}
|
||||
}
|
||||
private void FillTreeData(DebugOperationInfo parentOperation, TreeNode rootNode)
|
||||
{
|
||||
foreach (var childOperation in parentOperation.Childs)
|
||||
{
|
||||
var childNode = new TreeNode(childOperation);
|
||||
rootNode.AddChild(childNode);
|
||||
FillTreeData(childOperation, childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: faabdaf3787cba6438d2300f7f71e26f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,9 @@
|
||||
<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;">
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="BottomGroup" style="flex-grow: 1;">
|
||||
<uie:Toolbar name="BottomToolbar" />
|
||||
<YooAsset.Editor.TreeViewer name="BottomTreeView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7147c7108cba1bb4dba3a2cfc758ad43
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
Reference in New Issue
Block a user