From cbc841bce4adb794d99562254c6b3206f9b95010 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 594335145e056aa60a7aa568f83746823c8c5bd8 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 71427ee440..5ac5574df8 100644 --- a/Packages/com.unity.inputsystem/CHANGELOG.md +++ b/Packages/com.unity.inputsystem/CHANGELOG.md @@ -37,6 +37,7 @@ however, it has to be formatted properly to pass verification tests. - Fixed an editor crash caused by input debugger device state window reusing cached state when reconnecting Stadia controller. [ISXB-658](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-658) - Fixed an issue where batch jobs would fail with "Error: Error building Player because scripts are compiling" if a source generated .inputactions asset is out of sync with its generated source code (ISXB-1300). - Fixed multiple `OnScreenStick` Components that does not work together when using them simultaneously in isolation mode. [ISXB-813](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-813) +- 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 - Changed location of the link xml file (code stripping rules), from a temporary directory to the project Library folder (ISX-2140).