From 7c435f6dc008c51c55461d8a1f50e19b3503d90e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Mon, 20 Jan 2025 17:13:20 +0800 Subject: [PATCH] update UIElements --- .../DefaultCells/BooleanValueCell.cs | 40 +++++++++++++++++++ .../DefaultCells/BooleanValueCell.cs.meta | 11 +++++ .../DefaultTableData/DefaultTableData.cs | 9 ++++- .../Editor/UIElements/TableView/TableView.cs | 10 +++++ 4 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs create mode 100644 Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs.meta diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs new file mode 100644 index 00000000..2ccf0ac0 --- /dev/null +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs @@ -0,0 +1,40 @@ +#if UNITY_2019_4_OR_NEWER +using System; + +namespace YooAsset.Editor +{ + public class BooleanValueCell : ITableCell, IComparable + { + public object CellValue { set; get; } + public string HeaderTitle { private set; get; } + public bool BooleanValue + { + get + { + return (bool)CellValue; + } + } + + public BooleanValueCell(string headerTitle, object cellValue) + { + HeaderTitle = headerTitle; + CellValue = cellValue; + } + public object GetDisplayObject() + { + return CellValue.ToString(); + } + public int CompareTo(object other) + { + if (other is BooleanValueCell cell) + { + return this.BooleanValue.CompareTo(cell.BooleanValue); + } + else + { + return 1; + } + } + } +} +#endif \ No newline at end of file diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs.meta b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs.meta new file mode 100644 index 00000000..4310f3d1 --- /dev/null +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f7b1e743b81646b49b2c05721edcf9b4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs index f2c14f32..c3f747c0 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs @@ -34,16 +34,21 @@ namespace YooAsset.Editor var cell = new StringValueCell(headerTitle, value); Cells.Add(cell); } - public void AddIntegerValueCell(string headerTitle, long value) + public void AddLongValueCell(string headerTitle, long value) { var cell = new IntegerValueCell(headerTitle, value); Cells.Add(cell); } - public void AddSingleValueCell(string headerTitle, double value) + public void AddDoubleValueCell(string headerTitle, double value) { var cell = new SingleValueCell(headerTitle, value); Cells.Add(cell); } + public void AddBoolValueCell(string headerTitle, bool value) + { + var cell = new BooleanValueCell(headerTitle, value); + Cells.Add(cell); + } #endregion } } diff --git a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs index d44ac79f..39a27f8b 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs @@ -89,6 +89,16 @@ namespace YooAsset.Editor this.Add(_listView); } + /// + /// 设置标题 + /// + public void SetHeaderTitle(string elementName, string headerTitle) + { + var toolbarBtn = _toolbar.Q(elementName); + if (toolbarBtn != null) + toolbarBtn.text = headerTitle; + } + /// /// 添加单元列 ///