From c163d99e7fd1a272ae73ba378d8a62bd779aa09a Mon Sep 17 00:00:00 2001 From: jak Date: Thu, 12 Dec 2024 12:01:13 +0000 Subject: [PATCH 1/2] Added a UI rebuild mode enum and added it as a defaulted parameter to the state container dispatch and view base OnStateChanged - this gives us control over which state changes cause a UI rebuild --- .../InputActionsEditorSettingsProvider.cs | 2 +- .../UITKAssetEditor/InputActionsEditorWindow.cs | 2 +- .../Editor/UITKAssetEditor/StateContainer.cs | 17 ++++++++++++----- .../Views/CompositeBindingPropertiesView.cs | 2 +- .../Editor/UITKAssetEditor/Views/ViewBase.cs | 10 +++++++--- 5 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs index ac72e580f2..3ff81719c3 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs @@ -176,7 +176,7 @@ private void OnFocusOut(FocusOutEvent @event = null) DelayFocusLost(element == null); } - private void OnStateChanged(InputActionsEditorState newState) + private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode editorRebuildMode) { #if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST // No action, auto-saved on edit-focus lost diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs index 58b5782d1b..2595192d24 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs @@ -237,7 +237,7 @@ private void BuildUI() m_StateContainer.Initialize(rootVisualElement.Q("action-editor")); } - private void OnStateChanged(InputActionsEditorState newState) + private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode editorRebuildMode) { DirtyInputActionsEditorWindow(newState); m_State = newState; diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs index 47fe0c7da6..c962b71d54 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs @@ -7,9 +7,16 @@ namespace UnityEngine.InputSystem.Editor { + // Enum used to dictate if a state change should rebuild the Input Actions editor UI + internal enum UIRebuildMode + { + None, + Rebuild, + } + internal class StateContainer { - public event Action StateChanged; + public event Action StateChanged; private VisualElement m_RootVisualElement; private InputActionsEditorState m_State; @@ -21,7 +28,7 @@ public StateContainer(InputActionsEditorState initialState, string assetGUID) this.assetGUID = assetGUID; } - public void Dispatch(Command command) + public void Dispatch(Command command, UIRebuildMode editorRebuildMode = UIRebuildMode.Rebuild) { if (command == null) throw new ArgumentNullException(nameof(command)); @@ -36,7 +43,7 @@ public void Dispatch(Command command) // catch exceptions here or the UIToolkit scheduled event will keep firing forever. try { - StateChanged?.Invoke(m_State); + StateChanged?.Invoke(m_State, editorRebuildMode); } catch (Exception e) { @@ -55,9 +62,9 @@ public void Initialize(VisualElement rootVisualElement) m_RootVisualElement.Unbind(); m_RootVisualElement.TrackSerializedObjectValue(m_State.serializedObject, so => { - StateChanged?.Invoke(m_State); + StateChanged?.Invoke(m_State, UIRebuildMode.Rebuild); }); - StateChanged?.Invoke(m_State); + StateChanged?.Invoke(m_State, UIRebuildMode.Rebuild); rootVisualElement.Bind(m_State.serializedObject); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositeBindingPropertiesView.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositeBindingPropertiesView.cs index 3a2e2f4484..ae4517502f 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositeBindingPropertiesView.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositeBindingPropertiesView.cs @@ -42,7 +42,7 @@ public override void RedrawUI(ViewState viewState) viewState.parameterListView.onChange = () => { - Dispatch(Commands.UpdatePathNameAndValues(viewState.parameterListView.GetParameters(), viewState.selectedBindingPath)); + Dispatch(Commands.UpdatePathNameAndValues(viewState.parameterListView.GetParameters(), viewState.selectedBindingPath), UIRebuildMode.None); }; viewState.parameterListView.OnDrawVisualElements(rootElement); } diff --git a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs index bf21556711..aef27a6905 100644 --- a/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs +++ b/Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs @@ -26,8 +26,12 @@ protected ViewBase(VisualElement root, StateContainer stateContainer) m_ChildViews = new List(); } - protected void OnStateChanged(InputActionsEditorState state) + protected void OnStateChanged(InputActionsEditorState state, UIRebuildMode editorRebuildMode) { + // Return early if rebuilding the editor UI isn't required (ISXB-1171) + if (editorRebuildMode == UIRebuildMode.None) + return; + UpdateView(state); } @@ -70,9 +74,9 @@ public void DestroyChildView(TView view) where TView : IView view.DestroyView(); } - public void Dispatch(Command command) + public void Dispatch(Command command, UIRebuildMode editorRebuildMode = UIRebuildMode.Rebuild) { - stateContainer.Dispatch(command); + stateContainer.Dispatch(command, editorRebuildMode); } public abstract void RedrawUI(TViewState viewState); From 826d9b2b21a3f8de11bee0f780e8d938fc74bcd1 Mon Sep 17 00:00:00 2001 From: jak Date: Wed, 18 Dec 2024 11:11:55 +0000 Subject: [PATCH 2/2] Added changelog entry --- Packages/com.unity.inputsystem/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/com.unity.inputsystem/CHANGELOG.md b/Packages/com.unity.inputsystem/CHANGELOG.md index 2a36143974..b76efaae84 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -34,6 +34,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed an issue with default device selection when adding new Control Scheme. - Fixed an issue where action map delegates were not updated when the asset already assigned to the PlayerInput component were changed [ISXB-711](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-711). - Fixed Action properties edition in the UI Toolkit version of the Input Actions Asset editor. [ISXB-1277](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1277) +- Fixed an issue in input actions editor window that caused certain fields in custom input composite bindings to require multiple clicks to action / focus. [ISXB-1171](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1171) ### Changed - Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086).