Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Modifying or changing focus on composite bindings in the Input Actions Editor no longer cause a full UI rebuild #2094

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Packages/com.unity.inputsystem/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<InputActionsEditorState> StateChanged;
public event Action<InputActionsEditorState, UIRebuildMode> StateChanged;

private VisualElement m_RootVisualElement;
private InputActionsEditorState m_State;
Expand All @@ -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));
Expand All @@ -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)
{
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ protected ViewBase(VisualElement root, StateContainer stateContainer)
m_ChildViews = new List<IView>();
}

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);
}

Expand Down Expand Up @@ -70,9 +74,9 @@ public void DestroyChildView<TView>(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);
Expand Down
Loading