From a38b76eb8f1fd6f85053cd6517e06d493eb6513f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Wed, 22 Jan 2025 15:16:44 +0800 Subject: [PATCH] update UIElements --- .../TableView/DefaultCells/BooleanValueCell.cs | 2 +- .../TableView/DefaultCells/ButtonCell.cs | 5 +++++ .../TableView/DefaultCells/IntegerValueCell.cs | 2 +- .../TableView/DefaultCells/SingleValueCell.cs | 2 +- .../TableView/DefaultCells/StringValueCell.cs | 2 +- .../DefaultTableData/DefaultTableData.cs | 17 ++++++++++++----- .../Editor/UIElements/TableView/TableView.cs | 18 ++++++++++++++++++ 7 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs index ee7598c4..a187bea4 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/BooleanValueCell.cs @@ -32,7 +32,7 @@ namespace YooAsset.Editor } else { - return 1; + return 0; } } } diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/ButtonCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/ButtonCell.cs index 79016ac2..09a33f8b 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/ButtonCell.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/ButtonCell.cs @@ -6,7 +6,12 @@ namespace YooAsset.Editor public class ButtonCell : ITableCell, IComparable { public object CellValue { set; get; } + public string SearchTag { private set; get; } + public ButtonCell(string searchTag) + { + SearchTag = searchTag; + } public object GetDisplayObject() { return string.Empty; diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/IntegerValueCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/IntegerValueCell.cs index bb760b4c..1565e49b 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/IntegerValueCell.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/IntegerValueCell.cs @@ -32,7 +32,7 @@ namespace YooAsset.Editor } else { - return 1; + return 0; } } } diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/SingleValueCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/SingleValueCell.cs index e80f2df6..d40d4cee 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/SingleValueCell.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/SingleValueCell.cs @@ -32,7 +32,7 @@ namespace YooAsset.Editor } else { - return 1; + return 0; } } } diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/StringValueCell.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/StringValueCell.cs index 0ab0d0e9..1c17b28d 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/StringValueCell.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultCells/StringValueCell.cs @@ -32,7 +32,7 @@ namespace YooAsset.Editor } else { - return 1; + return 0; } } } diff --git a/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs b/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs index cdb0554f..90946248 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/DefaultTableData/DefaultTableData.cs @@ -1,8 +1,6 @@ #if UNITY_2019_4_OR_NEWER using System; using System.Collections.Generic; -using UnityEditor; -using UnityEngine; namespace YooAsset.Editor { @@ -18,10 +16,19 @@ namespace YooAsset.Editor /// public IList Cells { set; get; } = new List(); - #region 添加默认的单元格数据 - public void AddButtonCell() + + /// + /// 添加单元格数据 + /// + public void AddCell(ITableCell cell) { - var cell = new ButtonCell(); + Cells.Add(cell); + } + + #region 添加默认的单元格数据 + public void AddButtonCell(string searchTag) + { + var cell = new ButtonCell(searchTag); Cells.Add(cell); } public void AddAssetPathCell(string searchTag, string path) diff --git a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs index 39a27f8b..c326137e 100644 --- a/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs +++ b/Assets/YooAsset/Editor/UIElements/TableView/TableView.cs @@ -52,6 +52,23 @@ namespace YooAsset.Editor } } + /// + /// 选中的数据列表 + /// + public List selectedItems + { + get + { +#if UNITY_2020_3_OR_NEWER + return _listView.selectedItems.Cast().ToList(); +#else + List result = new List(); + result.Add(_listView.selectedItem as ITableData); + return result; +#endif + } + } + /// /// 单元视图交互事件 /// @@ -76,6 +93,7 @@ namespace YooAsset.Editor _listView = new ListView(); _listView.makeItem = MakeListViewElement; _listView.bindItem = BindListViewElement; + _listView.selectionType = SelectionType.Multiple; _listView.RegisterCallback(OnClickListItem); #if UNITY_2022_3_OR_NEWER