Skip to content

Commit 58bd3ec

Browse files
authored
FIX: Modifying or changing focus on composite bindings in the Input Actions Editor no longer cause a full UI rebuild (#2094)
1 parent 0cbfdfe commit 58bd3ec

File tree

6 files changed

+23
-11
lines changed

6 files changed

+23
-11
lines changed

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ however, it has to be formatted properly to pass verification tests.
3737
- 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)
3838
- 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).
3939
- 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)
40+
- 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)
4041

4142
### Changed
4243
- Changed location of the link xml file (code stripping rules), from a temporary directory to the project Library folder (ISX-2140).

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ private void OnFocusOut(FocusOutEvent @event = null)
176176
DelayFocusLost(element == null);
177177
}
178178

179-
private void OnStateChanged(InputActionsEditorState newState)
179+
private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode editorRebuildMode)
180180
{
181181
#if UNITY_INPUT_SYSTEM_INPUT_ACTIONS_EDITOR_AUTO_SAVE_ON_FOCUS_LOST
182182
// No action, auto-saved on edit-focus lost

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ private void BuildUI()
237237
m_StateContainer.Initialize(rootVisualElement.Q("action-editor"));
238238
}
239239

240-
private void OnStateChanged(InputActionsEditorState newState)
240+
private void OnStateChanged(InputActionsEditorState newState, UIRebuildMode editorRebuildMode)
241241
{
242242
DirtyInputActionsEditorWindow(newState);
243243
m_State = newState;

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/StateContainer.cs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@
77

88
namespace UnityEngine.InputSystem.Editor
99
{
10+
// Enum used to dictate if a state change should rebuild the Input Actions editor UI
11+
internal enum UIRebuildMode
12+
{
13+
None,
14+
Rebuild,
15+
}
16+
1017
internal class StateContainer
1118
{
12-
public event Action<InputActionsEditorState> StateChanged;
19+
public event Action<InputActionsEditorState, UIRebuildMode> StateChanged;
1320

1421
private VisualElement m_RootVisualElement;
1522
private InputActionsEditorState m_State;
@@ -21,7 +28,7 @@ public StateContainer(InputActionsEditorState initialState, string assetGUID)
2128
this.assetGUID = assetGUID;
2229
}
2330

24-
public void Dispatch(Command command)
31+
public void Dispatch(Command command, UIRebuildMode editorRebuildMode = UIRebuildMode.Rebuild)
2532
{
2633
if (command == null)
2734
throw new ArgumentNullException(nameof(command));
@@ -36,7 +43,7 @@ public void Dispatch(Command command)
3643
// catch exceptions here or the UIToolkit scheduled event will keep firing forever.
3744
try
3845
{
39-
StateChanged?.Invoke(m_State);
46+
StateChanged?.Invoke(m_State, editorRebuildMode);
4047
}
4148
catch (Exception e)
4249
{
@@ -55,9 +62,9 @@ public void Initialize(VisualElement rootVisualElement)
5562
m_RootVisualElement.Unbind();
5663
m_RootVisualElement.TrackSerializedObjectValue(m_State.serializedObject, so =>
5764
{
58-
StateChanged?.Invoke(m_State);
65+
StateChanged?.Invoke(m_State, UIRebuildMode.Rebuild);
5966
});
60-
StateChanged?.Invoke(m_State);
67+
StateChanged?.Invoke(m_State, UIRebuildMode.Rebuild);
6168
rootVisualElement.Bind(m_State.serializedObject);
6269
}
6370

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/CompositeBindingPropertiesView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public override void RedrawUI(ViewState viewState)
4242

4343
viewState.parameterListView.onChange = () =>
4444
{
45-
Dispatch(Commands.UpdatePathNameAndValues(viewState.parameterListView.GetParameters(), viewState.selectedBindingPath));
45+
Dispatch(Commands.UpdatePathNameAndValues(viewState.parameterListView.GetParameters(), viewState.selectedBindingPath), UIRebuildMode.None);
4646
};
4747
viewState.parameterListView.OnDrawVisualElements(rootElement);
4848
}

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/Views/ViewBase.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ protected ViewBase(VisualElement root, StateContainer stateContainer)
2626
m_ChildViews = new List<IView>();
2727
}
2828

29-
protected void OnStateChanged(InputActionsEditorState state)
29+
protected void OnStateChanged(InputActionsEditorState state, UIRebuildMode editorRebuildMode)
3030
{
31+
// Return early if rebuilding the editor UI isn't required (ISXB-1171)
32+
if (editorRebuildMode == UIRebuildMode.None)
33+
return;
34+
3135
UpdateView(state);
3236
}
3337

@@ -70,9 +74,9 @@ public void DestroyChildView<TView>(TView view) where TView : IView
7074
view.DestroyView();
7175
}
7276

73-
public void Dispatch(Command command)
77+
public void Dispatch(Command command, UIRebuildMode editorRebuildMode = UIRebuildMode.Rebuild)
7478
{
75-
stateContainer.Dispatch(command);
79+
stateContainer.Dispatch(command, editorRebuildMode);
7680
}
7781

7882
public abstract void RedrawUI(TViewState viewState);

0 commit comments

Comments
 (0)