增加搜索框

This commit is contained in:
邬春鹏
2025-06-04 16:38:42 +08:00
parent 4f62b249b4
commit 517830dbef
2 changed files with 76 additions and 46 deletions

View File

@@ -18,6 +18,11 @@ namespace YooAsset.Editor
window.minSize = new Vector2(800, 600);
}
private VisualElement _mainContainer;
private VisualElement _searchContainer;
private ToolbarSearchField _searchField;
private Button _saveButton;
private List<string> _collectorTypeList;
private List<RuleDisplayName> _activeRuleList;
@@ -89,6 +94,12 @@ namespace YooAsset.Editor
visualAsset.CloneTree(root);
_mainContainer = root.Q<VisualElement>("MainContainer");
_searchContainer = root.Q<VisualElement>("SearchContainer");
_searchField = root.Q<ToolbarSearchField>("SearchField");
_searchField.RegisterValueChangedCallback(OnSearchFieldValueChanged);
// 警示栏
_helpBoxContainer = root.Q("HelpBoxContainer");
@@ -358,6 +369,21 @@ namespace YooAsset.Editor
Debug.LogError(e.ToString());
}
}
private void OnSearchFieldValueChanged(ChangeEvent<string> evt)
{
if (string.IsNullOrEmpty(evt.newValue))
{
_mainContainer.style.display = DisplayStyle.Flex;
_searchContainer.style.display = DisplayStyle.None;
}
else
{
_mainContainer.style.display = DisplayStyle.None;
_searchContainer.style.display = DisplayStyle.Flex;
}
}
public void OnEnable()
{
Undo.undoRedoPerformed += RefreshWindow;

View File

@@ -4,7 +4,9 @@
<ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<uie:ToolbarSearchField name="SearchField" />
</uie:Toolbar>
<ui:VisualElement name="MainContainer" style="flex-grow: 1;">
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
<ui:VisualElement name="GlobalSettingsContainer">
@@ -28,7 +30,7 @@
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:ListView focusable="true" name="PackageListView" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" fixed-item-height="20" style="flex-grow: 1;" />
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
@@ -38,7 +40,7 @@
<ui:Label text="Groups" display-tooltip-when-elided="true" name="GroupTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:ListView focusable="true" name="GroupListView" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" fixed-item-height="20" style="flex-grow: 1;" />
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
@@ -56,4 +58,6 @@
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="SearchContainer" enabled="true" style="flex-grow: 1; visibility: visible; display: none;" />
</ui:UXML>