Skip to content

FIX: InputControl is not updated from the first time [ISXB-1221] #2221

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

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

K-Tone
Copy link
Collaborator

@K-Tone K-Tone commented Aug 6, 2025

Description

This aims fixing the problem where the InputControl picker won't apply the selected item every second time basically (only when auto-save was on). To be technically precise, it wasn't applying the selected item every time when the input actions window was dirty, which normally happens in two cases:

  • you add a new input action, the window is marked dirty, and then if you try to select a new binding it won't be set
  • you set a new binding, that marks the window dirty, and then you try selecting the binding another time, that won't work

The root cause for these issues is that our input picker drop-down menu is technically a separate EditorWindow that steals focus from the input actions window as it's open. This was unfortunate because the input actions window subscribes to focus loss in order to save changes and reload all the state as it does so. Practically, if the input actions window was dirty, you click on the picker, that changes focus and triggers auto-save right there. It re-creates all the backing for the window, but the picker uses SerializedProperties, it doesn't talk to data directly. Because of that, when the new assets are loaded as part of auto-save, it won't pick the right data up.

Hereby we propose to address that by avoiding auto-save at that sensitive moment in time while we're opening the drop-down thing for the input control picker.

Testing status & QA

Local testing, QA pending

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

Comments to reviewers

Please describe any additional information such as what to focus on, or historical info for the reviewers.

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@codecov-github-com
Copy link

codecov-github-com bot commented Aug 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...tem/Editor/ControlPicker/InputControlPathEditor.cs 0.00% 3 Missing ⚠️
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 0.00% 2 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2221      +/-   ##
===========================================
+ Coverage    68.10%   68.12%   +0.01%     
===========================================
  Files          367      367              
  Lines        53629    53633       +4     
===========================================
+ Hits         36524    36535      +11     
+ Misses       17105    17098       -7     
Flag Coverage Δ
linux_2021.3_pkg 5.46% <0.00%> (-0.01%) ⬇️
linux_2021.3_project 70.36% <0.00%> (-0.01%) ⬇️
linux_2022.3_pkg 5.23% <0.00%> (-0.01%) ⬇️
linux_2022.3_project 65.21% <0.00%> (-0.01%) ⬇️
linux_6000.0_pkg 5.24% <0.00%> (-0.01%) ⬇️
linux_6000.0_project 68.00% <0.00%> (-0.01%) ⬇️
linux_6000.1_pkg 5.24% <0.00%> (-0.01%) ⬇️
linux_6000.1_project 68.00% <0.00%> (-0.01%) ⬇️
linux_6000.2_pkg 5.24% <0.00%> (-0.01%) ⬇️
linux_6000.2_project 68.02% <0.00%> (+0.01%) ⬆️
linux_trunk_pkg 5.24% <0.00%> (-0.01%) ⬇️
linux_trunk_project 68.00% <0.00%> (-0.01%) ⬇️
mac_2021.3_pkg 5.45% <0.00%> (-0.01%) ⬇️
mac_2021.3_project 70.37% <0.00%> (-0.01%) ⬇️
mac_2022.3_pkg 5.22% <0.00%> (-0.01%) ⬇️
mac_2022.3_project 65.23% <0.00%> (-0.01%) ⬇️
mac_6000.0_pkg 5.23% <0.00%> (-0.01%) ⬇️
mac_6000.0_project 68.03% <0.00%> (-0.01%) ⬇️
mac_6000.1_pkg 5.23% <0.00%> (-0.01%) ⬇️
mac_6000.1_project 68.04% <0.00%> (+<0.01%) ⬆️
mac_6000.2_pkg 5.23% <0.00%> (-0.01%) ⬇️
mac_6000.2_project 68.03% <0.00%> (-0.01%) ⬇️
mac_trunk_pkg 5.23% <0.00%> (-0.01%) ⬇️
mac_trunk_project 68.03% <0.00%> (-0.01%) ⬇️
win_2021.3_pkg 5.45% <0.00%> (-0.01%) ⬇️
win_2021.3_project 70.45% <0.00%> (-0.01%) ⬇️
win_2022.3_pkg 5.23% <0.00%> (-0.01%) ⬇️
win_2022.3_project 65.31% <0.00%> (-0.01%) ⬇️
win_6000.0_pkg 5.24% <0.00%> (-0.01%) ⬇️
win_6000.0_project 68.10% <0.00%> (-0.01%) ⬇️
win_6000.1_pkg 5.24% <0.00%> (-0.01%) ⬇️
win_6000.1_project 68.10% <0.00%> (-0.01%) ⬇️
win_6000.2_pkg 5.24% <0.00%> (-0.01%) ⬇️
win_6000.2_project 68.10% <0.00%> (-0.01%) ⬇️
win_trunk_pkg 5.24% <0.00%> (-0.01%) ⬇️
win_trunk_project 68.10% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...KAssetEditor/InputActionsEditorSettingsProvider.cs 0.00% <ø> (ø)
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 50.52% <0.00%> (-0.18%) ⬇️
...tem/Editor/ControlPicker/InputControlPathEditor.cs 0.00% <0.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@K-Tone K-Tone changed the title Anthony/isxb fix input control picker ISXB-1221 Fix InputControl is not updated from the first time Aug 7, 2025
@K-Tone K-Tone added the bug Issues where existsing functionality misbehaves label Aug 7, 2025
@K-Tone K-Tone changed the title ISXB-1221 Fix InputControl is not updated from the first time FIX: InputControl is not updated from the first time [ISXB-1221] Aug 7, 2025
@@ -161,9 +161,11 @@ public void OnGUI(Rect rect, GUIContent label = null, SerializedProperty propert

private void ShowDropdown(Rect rect, SerializedProperty serializedProperty, Action modifiedCallback)
{
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
#if UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was automatic by VSCode

/// It's employed to skip auto-saving, because that complicates updating the internal SerializedProperties.
/// Unfortunately, we can't use IMGUIDropdownVisible from the setings provider because of the early-out logic in there.
/// </summary>
public static bool IsShowingDropdown { get; private set; }
Copy link
Collaborator Author

@K-Tone K-Tone Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is a static property. However, it's only set from one place (private set), and it won't leak memory. Also, if we somehow happen to have two drop-down editor windows at the same time (which QA will correct me is barely possible). Even if somehow somehow opens two drop-down thingies at the same time, I believe we're fine here, as the more drop-down windows we have, the less sense it makes to auto-save during those sensitive moments of time. Hope that makes sense.

@K-Tone K-Tone force-pushed the anthony/isxb-fix-input-control-picker branch from 95dbcf9 to f38d3ae Compare August 7, 2025 11:05
@K-Tone K-Tone marked this pull request as ready for review August 7, 2025 14:15
@K-Tone
Copy link
Collaborator Author

K-Tone commented Aug 7, 2025

I don't think I can make an automated test for this myself, it's rather tricky UI/Editor case involving ImGUI and UIElements among other things.

@@ -17,7 +17,6 @@ internal class InputActionsEditorSettingsProvider : SettingsProvider
[SerializeField] InputActionsEditorState m_State;
VisualElement m_RootVisualElement;
private bool m_HasEditFocus;
private bool m_IgnoreActionChangedCallback;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was never used, dead code, I'm removing as a harmless side effect.


private InputControlPickerDropdown m_PickerDropdown;
private readonly InputControlPickerState m_PickerState;
private InputActionRebindingExtensions.RebindingOperation m_RebindingOperation;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three private properties were never really used, so I'm just cleaning it up as a harmless side effect on my main change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues where existsing functionality misbehaves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant