update UIElements

pull/464/head
何冠峰 2025-02-05 18:49:11 +08:00
parent 7e1dc7ef24
commit 4e6c146bde
7 changed files with 80 additions and 296 deletions

View File

@ -319,25 +319,16 @@ namespace YooAsset.Editor
// 眼睛标题 // 眼睛标题
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(20);
columnStyle.Width = 20;
columnStyle.MinWidth = 20;
columnStyle.MaxWidth = 20;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("眼睛框", string.Empty, columnStyle); var column = new TableColumn("眼睛框", string.Empty, columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var toggle = new DisplayToggle(); var toggle = new DisplayToggle();
toggle.text = string.Empty; toggle.text = string.Empty;
toggle.style.marginLeft = 3f; toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
toggle.style.unityTextAlign = columnStyle.TxtAnchor;
toggle.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
toggle.style.width = columnStyle.Width;
toggle.style.maxWidth = columnStyle.MaxWidth;
toggle.style.minWidth = columnStyle.MinWidth;
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); }); toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
return toggle; return toggle;
}; };
@ -350,29 +341,22 @@ namespace YooAsset.Editor
toggle.RefreshIcon(); toggle.RefreshIcon();
}; };
_elementTableView.AddColumn(column); _elementTableView.AddColumn(column);
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
} }
// 通过标题 // 通过标题
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(70);
columnStyle.Width = 70;
columnStyle.MinWidth = 70;
columnStyle.MaxWidth = 70;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("通过", "通过", columnStyle); var column = new TableColumn("通过", "通过", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var button = new Button(); var button = new Button();
button.text = "通过"; button.text = "通过";
button.style.marginLeft = 3f; button.style.unityTextAlign = TextAnchor.MiddleCenter;
button.style.unityTextAlign = columnStyle.TxtAnchor;
button.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
button.style.width = columnStyle.Width;
button.style.maxWidth = columnStyle.MaxWidth;
button.style.minWidth = columnStyle.MinWidth;
button.SetEnabled(false); button.SetEnabled(false);
return button; return button;
}; };
@ -392,29 +376,22 @@ namespace YooAsset.Editor
} }
}; };
_elementTableView.AddColumn(column); _elementTableView.AddColumn(column);
var headerElement = _elementTableView.GetHeaderElement("通过");
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
} }
// 白名单标题 // 白名单标题
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(70);
columnStyle.Width = 70;
columnStyle.MinWidth = 70;
columnStyle.MaxWidth = 70;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("白名单", "白名单", columnStyle); var column = new TableColumn("白名单", "白名单", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
Button button = new Button(); Button button = new Button();
button.text = "白名单"; button.text = "白名单";
button.style.marginLeft = 3f; button.style.unityTextAlign = TextAnchor.MiddleCenter;
button.style.unityTextAlign = columnStyle.TxtAnchor;
button.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
button.style.width = columnStyle.Width;
button.style.maxWidth = columnStyle.MaxWidth;
button.style.minWidth = columnStyle.MinWidth;
button.clickable.clickedWithEventInfo += OnClickWhitListButton; button.clickable.clickedWithEventInfo += OnClickWhitListButton;
return button; return button;
}; };
@ -429,29 +406,22 @@ namespace YooAsset.Editor
button.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255)); button.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
}; };
_elementTableView.AddColumn(column); _elementTableView.AddColumn(column);
var headerElement = _elementTableView.GetHeaderElement("白名单");
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
} }
// 选中标题 // 选中标题
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(20);
columnStyle.Width = 20;
columnStyle.MinWidth = 20;
columnStyle.MaxWidth = 20;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("选中框", string.Empty, columnStyle); var column = new TableColumn("选中框", string.Empty, columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
var toggle = new Toggle(); var toggle = new Toggle();
toggle.text = string.Empty; toggle.text = string.Empty;
toggle.style.marginLeft = 3f; toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
toggle.style.unityTextAlign = columnStyle.TxtAnchor;
toggle.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
toggle.style.width = columnStyle.Width;
toggle.style.maxWidth = columnStyle.MaxWidth;
toggle.style.minWidth = columnStyle.MinWidth;
toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); }); toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); });
return toggle; return toggle;
}; };
@ -468,10 +438,7 @@ namespace YooAsset.Editor
// 自定义标题栏 // 自定义标题栏
foreach (var header in _reportCombiner.Headers) foreach (var header in _reportCombiner.Headers)
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(header.Width, header.MinWidth, header.MaxWidth);
columnStyle.Width = header.Width;
columnStyle.MinWidth = header.MinWidth;
columnStyle.MaxWidth = header.MaxWidth;
columnStyle.Stretchable = header.Stretchable; columnStyle.Stretchable = header.Stretchable;
columnStyle.Searchable = header.Searchable; columnStyle.Searchable = header.Searchable;
columnStyle.Sortable = header.Sortable; columnStyle.Sortable = header.Sortable;
@ -480,11 +447,7 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.marginLeft = 3f; label.style.marginLeft = 3f;
label.style.unityTextAlign = columnStyle.TxtAnchor; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>

View File

@ -64,8 +64,7 @@ namespace YooAsset.Editor
{ {
// PackageName // PackageName
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(200);
columnStyle.Width = 150;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -74,11 +73,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -91,8 +85,7 @@ namespace YooAsset.Editor
// AssetPath // AssetPath
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -101,11 +94,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -118,8 +106,7 @@ namespace YooAsset.Editor
// SpawnScene // SpawnScene
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(150);
columnStyle.Width = 150;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -128,11 +115,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -145,8 +127,7 @@ namespace YooAsset.Editor
// SpawnTime // SpawnTime
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -155,11 +136,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -172,8 +148,7 @@ namespace YooAsset.Editor
// LoadingTime // LoadingTime
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -182,11 +157,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -199,8 +169,7 @@ namespace YooAsset.Editor
// RefCount // RefCount
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -209,11 +178,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -226,8 +190,7 @@ namespace YooAsset.Editor
// Status // Status
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -236,11 +199,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -263,8 +221,7 @@ namespace YooAsset.Editor
{ {
//DependBundles //DependBundles
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -273,11 +230,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -290,8 +242,7 @@ namespace YooAsset.Editor
// RefCount // RefCount
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -300,11 +251,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -317,8 +263,7 @@ namespace YooAsset.Editor
// Status // Status
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -327,11 +272,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>

View File

@ -6,7 +6,6 @@ using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEditor.UIElements; using UnityEditor.UIElements;
using UnityEngine.UIElements; using UnityEngine.UIElements;
using System.Text;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
@ -65,8 +64,7 @@ namespace YooAsset.Editor
{ {
// PackageName // PackageName
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(200);
columnStyle.Width = 150;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -75,11 +73,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -92,8 +85,7 @@ namespace YooAsset.Editor
// BundleName // BundleName
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -102,11 +94,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -119,8 +106,7 @@ namespace YooAsset.Editor
// RefCount // RefCount
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -129,11 +115,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -146,8 +127,7 @@ namespace YooAsset.Editor
// Status // Status
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -156,11 +136,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -183,8 +158,7 @@ namespace YooAsset.Editor
{ {
// UsingAssets // UsingAssets
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -193,11 +167,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -210,8 +179,7 @@ namespace YooAsset.Editor
// SpawnScene // SpawnScene
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(150);
columnStyle.Width = 150;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -220,11 +188,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -237,8 +200,7 @@ namespace YooAsset.Editor
// SpawnTime // SpawnTime
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -247,11 +209,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -264,8 +221,7 @@ namespace YooAsset.Editor
// RefCount // RefCount
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -274,11 +230,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -291,8 +242,7 @@ namespace YooAsset.Editor
// Status // Status
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -301,11 +251,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>

View File

@ -68,8 +68,7 @@ namespace YooAsset.Editor
{ {
// AssetPath // AssetPath
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -78,11 +77,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -95,8 +89,7 @@ namespace YooAsset.Editor
//MainBundle //MainBundle
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 150;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -105,11 +98,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -124,8 +112,7 @@ namespace YooAsset.Editor
{ {
// DependBundles // DependBundles
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 280;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -134,11 +121,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -151,8 +133,7 @@ namespace YooAsset.Editor
// FileSize // FileSize
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -161,11 +142,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -179,8 +155,7 @@ namespace YooAsset.Editor
// FileHash // FileHash
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(250);
columnStyle.Width = 250;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
@ -189,11 +164,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>

View File

@ -68,8 +68,7 @@ namespace YooAsset.Editor
{ {
//BundleName //BundleName
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -78,11 +77,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -95,8 +89,7 @@ namespace YooAsset.Editor
// FileSize // FileSize
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -105,11 +98,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -123,8 +111,7 @@ namespace YooAsset.Editor
// FileHash // FileHash
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(250);
columnStyle.Width = 250;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
@ -133,11 +120,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -150,8 +132,7 @@ namespace YooAsset.Editor
//Encrypted //Encrypted
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -160,11 +141,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -178,8 +154,7 @@ namespace YooAsset.Editor
//Tags //Tags
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(150, 100, 1000);
columnStyle.Width = 150;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -188,11 +163,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -207,8 +177,7 @@ namespace YooAsset.Editor
{ {
//IncludeAssets //IncludeAssets
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Width = 300;
columnStyle.Stretchable = true; columnStyle.Stretchable = true;
columnStyle.Searchable = true; columnStyle.Searchable = true;
columnStyle.Sortable = true; columnStyle.Sortable = true;
@ -217,11 +186,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -234,8 +198,7 @@ namespace YooAsset.Editor
//AssetSource //AssetSource
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(100);
columnStyle.Width = 100;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
@ -244,11 +207,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -261,8 +219,7 @@ namespace YooAsset.Editor
//AssetGUID //AssetGUID
{ {
var columnStyle = new ColumnStyle(); var columnStyle = new ColumnStyle(250);
columnStyle.Width = 250;
columnStyle.Stretchable = false; columnStyle.Stretchable = false;
columnStyle.Searchable = false; columnStyle.Searchable = false;
columnStyle.Sortable = false; columnStyle.Sortable = false;
@ -271,11 +228,6 @@ namespace YooAsset.Editor
{ {
var label = new Label(); var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
label.style.minWidth = columnStyle.MinWidth;
return label; return label;
}; };
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) => column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>

View File

@ -14,22 +14,17 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 单元列宽度 /// 单元列宽度
/// </summary> /// </summary>
public Length Width = 100f; public Length Width;
/// <summary> /// <summary>
/// 单元列最小宽度 /// 单元列最小宽度
/// </summary> /// </summary>
public Length MinWidth = 30f; public Length MinWidth;
/// <summary> /// <summary>
/// 单元列最大宽度 /// 单元列最大宽度
/// </summary> /// </summary>
public Length MaxWidth = MaxValue; public Length MaxWidth;
/// <summary>
/// 文本的锚点类型
/// </summary>
public TextAnchor TxtAnchor = TextAnchor.MiddleLeft;
/// <summary> /// <summary>
/// 可伸缩 /// 可伸缩
@ -45,6 +40,25 @@ namespace YooAsset.Editor
/// 可排序 /// 可排序
/// </summary> /// </summary>
public bool Sortable = false; public bool Sortable = false;
public ColumnStyle(Length width)
{
if (width.value > MaxValue)
width = MaxValue;
Width = width;
MinWidth = width;
MaxWidth = width;
}
public ColumnStyle(Length width, Length minWidth, Length maxWidth)
{
if (maxWidth.value > MaxValue)
maxWidth = MaxValue;
Width = width;
MinWidth = minWidth;
MaxWidth = maxWidth;
}
} }
} }
#endif #endif

View File

@ -108,13 +108,11 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 设置标题 /// 获取标题UI元素
/// </summary> /// </summary>
public void SetHeaderTitle(string elementName, string headerTitle) public VisualElement GetHeaderElement(string elementName)
{ {
var toolbarBtn = _toolbar.Q<ToolbarButton>(elementName); return _toolbar.Q<ToolbarButton>(elementName);
if (toolbarBtn != null)
toolbarBtn.text = headerTitle;
} }
/// <summary> /// <summary>
@ -126,7 +124,6 @@ namespace YooAsset.Editor
toolbarBtn.userData = column; toolbarBtn.userData = column;
toolbarBtn.name = column.ElementName; toolbarBtn.name = column.ElementName;
toolbarBtn.text = column.HeaderTitle; toolbarBtn.text = column.HeaderTitle;
toolbarBtn.style.unityTextAlign = column.ColumnStyle.TxtAnchor;
toolbarBtn.style.flexGrow = 0; toolbarBtn.style.flexGrow = 0;
toolbarBtn.style.width = column.ColumnStyle.Width; toolbarBtn.style.width = column.ColumnStyle.Width;
toolbarBtn.style.minWidth = column.ColumnStyle.Width; toolbarBtn.style.minWidth = column.ColumnStyle.Width;
@ -311,14 +308,17 @@ namespace YooAsset.Editor
{ {
VisualElement listViewElement = new VisualElement(); VisualElement listViewElement = new VisualElement();
listViewElement.style.flexDirection = FlexDirection.Row; listViewElement.style.flexDirection = FlexDirection.Row;
foreach (var colum in _columns) foreach (var column in _columns)
{ {
var cellElement = colum.MakeCell.Invoke(); var cellElement = column.MakeCell.Invoke();
cellElement.name = colum.ElementName; cellElement.name = column.ElementName;
cellElement.style.flexGrow = 0f; cellElement.style.flexGrow = 0f;
cellElement.style.width = column.ColumnStyle.Width;
cellElement.style.minWidth = column.ColumnStyle.Width;
cellElement.style.maxWidth = column.ColumnStyle.Width;
SetCellElementStyle(cellElement); SetCellElementStyle(cellElement);
listViewElement.Add(cellElement); listViewElement.Add(cellElement);
colum.CellElements.Add(cellElement); column.CellElements.Add(cellElement);
} }
return listViewElement; return listViewElement;
} }