Update AssetBundleDebugger

界面增加了包裹名称显示列。
pull/51/head
hevinci 2022-10-22 15:39:26 +08:00
parent c196e44bc6
commit 8eb7816e30
4 changed files with 91 additions and 34 deletions

View File

@ -72,15 +72,24 @@ namespace YooAsset.Editor
}
private List<DebugProviderInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
{
var result = new List<DebugProviderInfo>(debugReport.ProviderInfos.Count);
foreach (var providerInfo in debugReport.ProviderInfos)
List<DebugProviderInfo> result = new List<DebugProviderInfo>(1000);
foreach (var packageData in debugReport.PackageDatas)
{
if (string.IsNullOrEmpty(searchKeyWord) == false)
var tempList = new List<DebugProviderInfo>(packageData.ProviderInfos.Count);
foreach (var providerInfo in packageData.ProviderInfos)
{
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
continue;
if (string.IsNullOrEmpty(searchKeyWord) == false)
{
if (providerInfo.AssetPath.Contains(searchKeyWord) == false)
continue;
}
providerInfo.PackageName = packageData.PackageName;
tempList.Add(providerInfo);
}
result.Add(providerInfo);
tempList.Sort();
result.AddRange(tempList);
}
return result;
}
@ -102,12 +111,22 @@ namespace YooAsset.Editor
}
// 资源列表相关
// 顶部列表相关
private VisualElement MakeAssetListViewItem()
{
VisualElement element = new VisualElement();
element.style.flexDirection = FlexDirection.Row;
{
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";
@ -165,6 +184,10 @@ namespace YooAsset.Editor
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;
@ -200,7 +223,7 @@ namespace YooAsset.Editor
}
}
// 依赖列表相关
// 底部列表相关
private VisualElement MakeDependListViewItem()
{
VisualElement element = new VisualElement();
@ -255,11 +278,11 @@ namespace YooAsset.Editor
var label4 = element.Q<Label>("Label4");
label4.text = bundleInfo.Status.ToString();
}
private void FillDependListView(DebugProviderInfo providerInfo)
private void FillDependListView(DebugProviderInfo selectedProviderInfo)
{
_dependListView.Clear();
_dependListView.ClearSelection();
_dependListView.itemsSource = providerInfo.DependBundleInfos;
_dependListView.itemsSource = selectedProviderInfo.DependBundleInfos;
_dependListView.Rebuild();
}
}

View File

@ -1,6 +1,7 @@
<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;" />

View File

@ -33,8 +33,8 @@ namespace YooAsset.Editor
// 资源包列表
_bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeAssetListViewItem;
_bundleListView.bindItem = BindAssetListViewItem;
_bundleListView.makeItem = MakeBundleListViewItem;
_bundleListView.bindItem = BindBundleListViewItem;
#if UNITY_2020_1_OR_NEWER
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
#else
@ -72,21 +72,33 @@ namespace YooAsset.Editor
}
private List<DebugBundleInfo> FilterViewItems(DebugReport debugReport, string searchKeyWord)
{
Dictionary<string, DebugBundleInfo> result = new Dictionary<string, DebugBundleInfo>(debugReport.ProviderInfos.Count);
foreach (var providerInfo in debugReport.ProviderInfos)
List<DebugBundleInfo> result = new List<DebugBundleInfo>(1000);
foreach (var pakcageData in debugReport.PackageDatas)
{
foreach (var bundleInfo in providerInfo.DependBundleInfos)
Dictionary<string, DebugBundleInfo> tempDic = new Dictionary<string, DebugBundleInfo>(1000);
foreach (var providerInfo in pakcageData.ProviderInfos)
{
if (string.IsNullOrEmpty(searchKeyWord) == false)
foreach (var bundleInfo in providerInfo.DependBundleInfos)
{
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
continue;
if (string.IsNullOrEmpty(searchKeyWord) == false)
{
if (bundleInfo.BundleName.Contains(searchKeyWord) == false)
continue;
}
if (tempDic.ContainsKey(bundleInfo.BundleName) == false)
{
bundleInfo.PackageName = pakcageData.PackageName;
tempDic.Add(bundleInfo.BundleName, bundleInfo);
}
}
if (result.ContainsKey(bundleInfo.BundleName) == false)
result.Add(bundleInfo.BundleName, bundleInfo);
}
var tempList = tempDic.Values.ToList();
tempList.Sort();
result.AddRange(tempList);
}
return result.Values.ToList();
return result;
}
/// <summary>
@ -107,11 +119,21 @@ namespace YooAsset.Editor
// 顶部列表相关
private VisualElement MakeAssetListViewItem()
private VisualElement MakeBundleListViewItem()
{
VisualElement element = new VisualElement();
element.style.flexDirection = FlexDirection.Row;
{
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";
@ -144,11 +166,15 @@ namespace YooAsset.Editor
return element;
}
private void BindAssetListViewItem(VisualElement element, int index)
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;
@ -172,7 +198,7 @@ namespace YooAsset.Editor
foreach (var item in objs)
{
DebugBundleInfo bundleInfo = item as DebugBundleInfo;
FillUsingListView(bundleInfo.BundleName);
FillUsingListView(bundleInfo);
}
}
@ -259,17 +285,23 @@ namespace YooAsset.Editor
var label5 = element.Q<Label>("Label5");
label5.text = providerInfo.Status.ToString();
}
private void FillUsingListView(string bundleName)
private void FillUsingListView(DebugBundleInfo selectedBundleInfo)
{
List<DebugProviderInfo> source = new List<DebugProviderInfo>();
foreach (var providerInfo in _debugReport.ProviderInfos)
foreach (var packageData in _debugReport.PackageDatas)
{
foreach (var bundleInfo in providerInfo.DependBundleInfos)
if (packageData.PackageName == selectedBundleInfo.PackageName)
{
if (bundleInfo.BundleName == bundleName)
foreach (var providerInfo in packageData.ProviderInfos)
{
source.Add(providerInfo);
continue;
foreach (var bundleInfo in providerInfo.DependBundleInfos)
{
if (bundleInfo.BundleName == selectedBundleInfo.BundleName)
{
source.Add(providerInfo);
continue;
}
}
}
}
}

View File

@ -1,6 +1,7 @@
<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;" />