diff --git a/Editor/GameplayTagContainerTreeView.cs b/Editor/GameplayTagContainerTreeView.cs index 74e590a..906e288 100644 --- a/Editor/GameplayTagContainerTreeView.cs +++ b/Editor/GameplayTagContainerTreeView.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEditor; using UnityEditor.IMGUI.Controls; using UnityEngine; @@ -39,6 +40,17 @@ protected override void RowGUI(RowGUIArgs args) GameplayTagTreeViewItem item = args.item as GameplayTagTreeViewItem; bool added; + + if (IsSelected(item.id) && Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp) + { + if (!item.IsIncluded || !item.IsExplicitIncluded) + AddTag(item.Tag); + else + RemoveTag(item.Tag); + + Repaint(); // Have to repaint or the Toggle GUI is not updated accordingly + } + EditorGUI.BeginChangeCheck(); EditorGUI.showMixedValue = item.IsIncluded && !item.IsExplicitIncluded; added = EditorGUI.Toggle(rect, s_TempContent, item.IsIncluded); diff --git a/Editor/GameplayTagTreeView.cs b/Editor/GameplayTagTreeView.cs index 967fe85..1f8e4ce 100644 --- a/Editor/GameplayTagTreeView.cs +++ b/Editor/GameplayTagTreeView.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEditor; using UnityEditor.IMGUI.Controls; using UnityEngine; @@ -69,6 +70,15 @@ protected override void RowGUI(RowGUIArgs args) GameplayTagTreeViewItem item = args.item as GameplayTagTreeViewItem; + + if (IsSelected(item.id) && Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.KeyUp) + { + m_TagNameProperty.stringValue = item.Tag.Name; + m_TagNameProperty.serializedObject.ApplyModifiedProperties(); + + m_OnSelectionChange?.Invoke(); + } + if (GUI.Button(rect, s_TempContent, EditorStyles.label)) { m_TagNameProperty.stringValue = item.Tag.Name; diff --git a/Editor/GameplayTagTreeViewBase.cs b/Editor/GameplayTagTreeViewBase.cs index 9044890..c3dedb3 100644 --- a/Editor/GameplayTagTreeViewBase.cs +++ b/Editor/GameplayTagTreeViewBase.cs @@ -83,6 +83,9 @@ public GameplayTagTreeViewBase(TreeViewState treeViewState) rowHeight = 24; Reload(); + + m_SearchField.SetFocus(); + m_SearchField.downOrUpArrowKeyPressed += SetFocusAndEnsureSelectedItem; } public override void OnGUI(Rect rect)