diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index bf238bff51..00a06c6348 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -13,6 +13,7 @@ however, it has to be formatted properly to pass verification tests. ### Fixed - Fixed Multiple interactions could breaks on Composite Binding. [ISXB-619](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-619) - Fixed memory leak when the OnScreenStick component was destroyed [ISXB-1070](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1070). Contribution by [LukeUnityDev](https://github.com/LukeUnityDev). +- Fixed Action Maps contextual menu in Action Editor UI that occasionally displays unrelated items. ### Changed - Renamed editor Resources directories to PackageResources to fix package validation warnings. diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ContextMenu.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ContextMenu.cs index 1ec973f564..a8163243e3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ContextMenu.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ContextMenu.cs @@ -27,7 +27,7 @@ internal static class ContextMenu #region ActionMaps public static void GetContextMenuForActionMapItem(ActionMapsView mapView, InputActionMapsTreeViewItem treeViewItem, int index) { - _ = new ContextualMenuManipulator(menuEvent => + treeViewItem.OnContextualMenuPopulateEvent = (menuEvent => { // TODO: AddAction should enable m_RenameOnActionAdded menuEvent.menu.AppendAction(add_Action_String, _ => mapView.Dispatch(Commands.AddAction())); @@ -42,7 +42,7 @@ public static void GetContextMenuForActionMapItem(ActionMapsView mapView, InputA var copiedAction = CopyPasteHelper.GetCopiedClipboardType() == typeof(InputAction); if (CopyPasteHelper.HasPastableClipboardData(typeof(InputActionMap))) menuEvent.menu.AppendAction(paste_String, _ => mapView.PasteItems(copiedAction)); - }) { target = treeViewItem }; + }); } // Add "Add Action Map" option to empty space under the ListView. Matches with old IMGUI style (ISX-1519). diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionMapsTreeViewItem.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionMapsTreeViewItem.cs index 126e78feab..8c99f99ae4 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionMapsTreeViewItem.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/InputActionMapsTreeViewItem.cs @@ -1,6 +1,7 @@ // UITK TreeView is not supported in earlier versions // Therefore the UITK version of the InputActionAsset Editor is not available on earlier Editor versions either. #if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS +using System; using System.Threading.Tasks; using UnityEditor; using UnityEngine.InputSystem.Editor; @@ -17,6 +18,7 @@ internal class InputActionMapsTreeViewItem : VisualElement private const string kRenameTextField = "rename-text-field"; public event EventCallback EditTextFinished; + public Action OnContextualMenuPopulateEvent; // for testing purposes to know if the item is focused to accept input internal bool IsFocused { get; private set; } = false; @@ -41,6 +43,11 @@ public InputActionMapsTreeViewItem() RegisterCallback(OnMouseDownEventForRename); renameTextfield.RegisterCallback(e => IsFocused = true); renameTextfield.RegisterCallback(e => { OnEditTextFinished(); IsFocused = false; }); + _ = new ContextualMenuManipulator(menuBuilder => + { + OnContextualMenuPopulateEvent?.Invoke(menuBuilder); + }) + { target = this }; } public Label label => this.Q