update asset art reporter

pull/464/head
何冠峰 2025-01-24 00:43:16 +08:00
parent 57d1e92e59
commit 31a89fa1a3
8 changed files with 185 additions and 56 deletions

View File

@ -80,7 +80,7 @@ namespace YooAsset.Editor
}
public int CompareTo(object other)
{
if (other is PassesBtnCell cell)
if (other is WhiteListBtnCell cell)
{
return this.Element.IsWhiteList.CompareTo(cell.Element.IsWhiteList);
}
@ -92,8 +92,9 @@ namespace YooAsset.Editor
}
private ToolbarSearchField _searchField;
private Button _whiteVisibleBtn;
private Button _stateVisibleBtn;
private Button _showHiddenBtn;
private Button _whiteListVisibleBtn;
private Button _passesVisibleBtn;
private Label _titleLabel;
private Label _descLabel;
private TableView _elementTableView;
@ -101,9 +102,9 @@ namespace YooAsset.Editor
private ScanReportCombiner _reportCombiner;
private string _lastestOpenFolder;
private List<ITableData> _sourceDatas;
private bool _showWhiteElements = true;
private bool _showPassesElements = true;
private bool _elementVisibleState = true;
private bool _whiteListVisibleState = true;
private bool _passesVisibleState = true;
public void CreateGUI()
{
@ -130,11 +131,13 @@ namespace YooAsset.Editor
var fixSelectBtn = root.Q<Button>("FixSelectButton");
fixSelectBtn.clicked += FixSelectBtn_clicked;
// 白名单按钮
_whiteVisibleBtn = root.Q<Button>("WhiteVisibleButton");
_whiteVisibleBtn.clicked += WhiteVisibleBtn_clicked;
_stateVisibleBtn = root.Q<Button>("StateVisibleButton");
_stateVisibleBtn.clicked += StateVsibleBtn_clicked;
// 可见性按钮
_showHiddenBtn = root.Q<Button>("ShowHiddenButton");
_showHiddenBtn.clicked += ShowHiddenBtn_clicked;
_whiteListVisibleBtn = root.Q<Button>("WhiteListVisibleButton");
_whiteListVisibleBtn.clicked += WhiteListVisibleBtn_clicked;
_passesVisibleBtn = root.Q<Button>("PassesVisibleButton");
_passesVisibleBtn.clicked += PassesVsibleBtn_clicked;
// 文件导出按钮
var exportFilesBtn = root.Q<Button>("ExportFilesButton");
@ -150,7 +153,7 @@ namespace YooAsset.Editor
// 列表相关
_elementTableView = root.Q<TableView>("TopTableView");
_elementTableView.ClickTableDataEvent = OnClickListItem;
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
_lastestOpenFolder = EditorTools.GetProjectPath();
}
@ -253,15 +256,21 @@ namespace YooAsset.Editor
_reportCombiner.FixSelect();
}
}
private void WhiteVisibleBtn_clicked()
private void ShowHiddenBtn_clicked()
{
_showWhiteElements = !_showWhiteElements;
_elementVisibleState = !_elementVisibleState;
RefreshToolbar();
RebuildView();
}
private void StateVsibleBtn_clicked()
private void WhiteListVisibleBtn_clicked()
{
_showPassesElements = !_showPassesElements;
_whiteListVisibleState = !_whiteListVisibleState;
RefreshToolbar();
RebuildView();
}
private void PassesVsibleBtn_clicked()
{
_passesVisibleState = !_passesVisibleState;
RefreshToolbar();
RebuildView();
}
@ -283,15 +292,23 @@ namespace YooAsset.Editor
_titleLabel.text = _reportCombiner.ReportTitle;
_descLabel.text = _reportCombiner.ReportDesc;
if (_showWhiteElements)
_whiteVisibleBtn.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
else
_whiteVisibleBtn.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
var enableColor = new Color32(18, 100, 18, 255);
var disableColor = new Color32(100, 100, 100, 255);
if (_showPassesElements)
_stateVisibleBtn.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
if (_elementVisibleState)
_showHiddenBtn.style.backgroundColor = new StyleColor(enableColor);
else
_stateVisibleBtn.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
_showHiddenBtn.style.backgroundColor = new StyleColor(disableColor);
if (_whiteListVisibleState)
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
else
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
if (_passesVisibleState)
_passesVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
else
_passesVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
}
private void FillTableView()
{
@ -300,27 +317,63 @@ namespace YooAsset.Editor
_elementTableView.ClearAll(true, true);
// 状态标题
// 眼睛标题
{
var columnStyle = new ColumnStyle();
columnStyle.Width = 80;
columnStyle.MinWidth = 80;
columnStyle.MaxWidth = 80;
columnStyle.Width = 20;
columnStyle.MinWidth = 20;
columnStyle.MaxWidth = 20;
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
column.MakeCell = () =>
{
var toggle = new DisplayToggle();
toggle.text = string.Empty;
toggle.style.marginLeft = 3f;
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); });
return toggle;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
{
var toggle = element as DisplayToggle;
toggle.userData = data;
var tableData = data as ElementTableData;
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
toggle.RefreshIcon();
};
_elementTableView.AddColumn(column);
}
// 通过标题
{
var columnStyle = new ColumnStyle();
columnStyle.Width = 70;
columnStyle.MinWidth = 70;
columnStyle.MaxWidth = 70;
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("状态", "状态", columnStyle);
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("通过", "通过", columnStyle);
column.MakeCell = () =>
{
var button = new Button();
button.text = "状态";
button.style.unityTextAlign = TextAnchor.MiddleCenter;
button.text = "通过";
button.style.marginLeft = 3f;
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);
return button;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -344,19 +397,20 @@ namespace YooAsset.Editor
// 白名单标题
{
var columnStyle = new ColumnStyle();
columnStyle.Width = 80;
columnStyle.MinWidth = 80;
columnStyle.MaxWidth = 80;
columnStyle.Width = 70;
columnStyle.MinWidth = 70;
columnStyle.MaxWidth = 70;
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("白名单", "白名单", columnStyle);
column.MakeCell = () =>
{
Button button = new Button();
button.text = "白名单";
button.style.unityTextAlign = TextAnchor.MiddleCenter;
button.style.marginLeft = 3f;
button.style.unityTextAlign = columnStyle.TxtAnchor;
button.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
button.style.width = columnStyle.Width;
button.style.maxWidth = columnStyle.MaxWidth;
@ -386,18 +440,19 @@ namespace YooAsset.Editor
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
columnStyle.TxtAnchor = TextAnchor.MiddleCenter;
var column = new TableColumn("选中框", string.Empty, columnStyle);
column.MakeCell = () =>
{
var toggle = new Toggle();
toggle.text = string.Empty;
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
toggle.style.marginLeft = 3f;
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) => { OnToggleValueChange(toggle, evt); });
toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); });
return toggle;
};
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
@ -424,8 +479,8 @@ namespace YooAsset.Editor
column.MakeCell = () =>
{
var label = new Label();
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.unityTextAlign = columnStyle.TxtAnchor;
label.style.flexGrow = columnStyle.Stretchable ? 1f : 0f;
label.style.width = columnStyle.Width;
label.style.maxWidth = columnStyle.MaxWidth;
@ -448,7 +503,8 @@ namespace YooAsset.Editor
tableData.Element = element;
// 固定标题
tableData.AddCell(new PassesBtnCell("状态", element));
tableData.AddButtonCell("眼睛框");
tableData.AddCell(new PassesBtnCell("通过", element));
tableData.AddCell(new WhiteListBtnCell("白名单", element));
tableData.AddButtonCell("选中框");
@ -498,12 +554,17 @@ namespace YooAsset.Editor
foreach (var tableData in _sourceDatas)
{
var elementTableData = tableData as ElementTableData;
if (_showPassesElements == false && elementTableData.Element.Passes)
if (_elementVisibleState == false && elementTableData.Element.Hidden)
{
tableData.Visible = false;
continue;
}
if (_showWhiteElements == false && elementTableData.Element.IsWhiteList)
if (_passesVisibleState == false && elementTableData.Element.Passes)
{
tableData.Visible = false;
continue;
}
if (_whiteListVisibleState == false && elementTableData.Element.IsWhiteList)
{
tableData.Visible = false;
continue;
@ -514,7 +575,7 @@ namespace YooAsset.Editor
_elementTableView.RebuildView();
}
private void OnClickListItem(PointerDownEvent evt, ITableData tableData)
private void OnClickTableViewItem(PointerDownEvent evt, ITableData tableData)
{
// 双击后检视对应的资源
if (evt.clickCount == 2)
@ -533,10 +594,12 @@ namespace YooAsset.Editor
{
RebuildView();
}
private void OnToggleValueChange(Toggle toggle, ChangeEvent<bool> e)
private void OnSelectToggleValueChange(Toggle toggle, ChangeEvent<bool> e)
{
// 处理自身
toggle.SetValueWithoutNotify(e.newValue);
// 记录数据
var elementTableData = toggle.userData as ElementTableData;
elementTableData.Element.IsSelected = e.newValue;
@ -551,6 +614,28 @@ namespace YooAsset.Editor
// 重绘视图
RebuildView();
}
private void OnDisplayToggleValueChange(DisplayToggle toggle, ChangeEvent<bool> e)
{
toggle.RefreshIcon();
// 处理自身
toggle.SetValueWithoutNotify(e.newValue);
// 记录数据
var elementTableData = toggle.userData as ElementTableData;
elementTableData.Element.Hidden = e.newValue;
// 处理多选目标
var selectedItems = _elementTableView.selectedItems;
foreach (var selectedItem in selectedItems)
{
var selectElement = selectedItem as ElementTableData;
selectElement.Element.Hidden = e.newValue;
}
// 重绘视图
RebuildView();
}
private void OnClickWhitListButton(EventBase evt)
{
// 刷新点击的按钮

View File

@ -1,18 +1,21 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
<ui:Button text="Show Passes" display-tooltip-when-elided="true" name="StateVisibleButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Show WhiteList" display-tooltip-when-elided="true" name="WhiteVisibleButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Export Select" display-tooltip-when-elided="true" name="ExportFilesButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Fix Select" display-tooltip-when-elided="true" name="FixSelectButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Fix All" display-tooltip-when-elided="true" name="FixAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Import Single" display-tooltip-when-elided="true" name="SingleImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Import Multiple " display-tooltip-when-elided="true" name="MultiImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Export Select" display-tooltip-when-elided="true" name="ExportFilesButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text=" Multi-Import" display-tooltip-when-elided="true" name="MultiImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Import" display-tooltip-when-elided="true" name="SingleImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar>
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Label text="标题" display-tooltip-when-elided="true" name="ReportTitle" style="height: 16px; -unity-font-style: bold; -unity-text-align: middle-center;" />
<ui:Label text="说明" display-tooltip-when-elided="true" name="ReportDesc" style="-unity-text-align: upper-left; -unity-font-style: bold; background-color: rgb(42, 42, 42); min-height: 50px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; white-space: normal;" />
</ui:VisualElement>
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
<ui:Button text="显示隐藏元素" display-tooltip-when-elided="true" name="ShowHiddenButton" style="width: 100px;" />
<ui:Button text="显示通过元素" display-tooltip-when-elided="true" name="PassesVisibleButton" style="width: 100px;" />
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
</uie:Toolbar>
<ui:VisualElement name="AssetGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" />
</ui:VisualElement>

View File

@ -62,6 +62,11 @@ namespace YooAsset.Editor
/// 是否在白名单里
/// </summary>
public bool IsWhiteList { set; get; }
/// <summary>
/// 是否隐藏元素
/// </summary>
public bool Hidden { set; get; }
#endregion
}
}

View File

@ -161,7 +161,8 @@ namespace YooAsset.Editor
}
/// <summary>
/// 修复所有(排除白名单)
/// 修复所有元素
/// 注意:排除白名单和隐藏元素
/// </summary>
public void FixAll()
{
@ -173,7 +174,7 @@ namespace YooAsset.Editor
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
foreach (var element in elements)
{
if (element.Passes || element.IsWhiteList)
if (element.Passes || element.IsWhiteList || element.Hidden)
continue;
fixList.Add(element);
}
@ -182,7 +183,8 @@ namespace YooAsset.Editor
}
/// <summary>
/// 修复选择项(包含白名单)
/// 修复选定元素
/// 注意:排除白名单和隐藏元素
/// </summary>
public void FixSelect()
{
@ -194,7 +196,7 @@ namespace YooAsset.Editor
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
foreach (var element in elements)
{
if (element.Passes)
if (element.Passes || element.IsWhiteList || element.Hidden)
continue;
if (element.IsSelected)
fixList.Add(element);

View File

@ -25,7 +25,12 @@ namespace YooAsset.Editor
/// 单元列最大宽度
/// </summary>
public Length MaxWidth = MaxValue;
/// <summary>
/// 文本的锚点类型
/// </summary>
public TextAnchor TxtAnchor = TextAnchor.MiddleLeft;
/// <summary>
/// 可伸缩
/// </summary>

View File

@ -126,7 +126,7 @@ namespace YooAsset.Editor
toolbarBtn.userData = column;
toolbarBtn.name = column.ElementName;
toolbarBtn.text = column.HeaderTitle;
toolbarBtn.style.unityTextAlign = TextAnchor.MiddleLeft;
toolbarBtn.style.unityTextAlign = column.ColumnStyle.TxtAnchor;
toolbarBtn.style.flexGrow = column.ColumnStyle.Stretchable ? 1f : 0f;
toolbarBtn.style.width = column.ColumnStyle.Width;
toolbarBtn.style.minWidth = column.ColumnStyle.MinWidth;

View File

@ -41,5 +41,36 @@ namespace YooAsset.Editor
root.Add(spliteView);
}
}
/// <summary>
/// 显示开关(眼睛图标)
/// </summary>
public class DisplayToggle : Toggle
{
private readonly VisualElement _checkbox;
public DisplayToggle()
{
_checkbox = this.Q<VisualElement>("unity-checkmark");
RefreshIcon();
}
/// <summary>
/// 刷新图标
/// </summary>
public void RefreshIcon()
{
if (this.value)
{
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleoff@2x").image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
else
{
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleon@2x").image as Texture2D;
_checkbox.style.backgroundImage = icon;
}
}
}
}
#endif

View File

@ -1,7 +1,6 @@

namespace YooAsset.Editor
{
#if UNITY_2019
public static partial class UnityEngine_UIElements_ListView_Extension
{
@ -21,5 +20,4 @@ namespace YooAsset.Editor
}
}
#endif
}