Skip to content

FIX: disabling the InputSystemUIInputModule component resets all actions to None #2192

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

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

Conversation

K-Tone
Copy link
Collaborator

@K-Tone K-Tone commented Jun 5, 2025

Description

This PR fixes a problem where disabling the InputSystemUIInputModule component would reset all the actions, even if they had been priorly set by user.

This started to happen after a fix for another regression landed, where we unassigned all actions from the components OnDisable. I believe this is wrong, since the only thing we really need to be resetting is the default actions asset that shouldn't normally survive re-reentering playmode.

Testing status & QA

Local testing, a new regression test, pending a QA pass

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

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.

@@ -1665,7 +1676,6 @@ protected override void OnDisable()
InputActionState.s_GlobalState.onActionControlsChanged.RemoveCallback(m_OnControlsChangedDelegate);
DisableAllActions();
UnhookActions();
UnassignActions();
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 line is very wrong, it results in user data being lost on component deactivation.

@codecov-github-com
Copy link

codecov-github-com bot commented Jun 5, 2025

Codecov Report

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

Files with missing lines Patch % Lines
...InputSystem/Plugins/UI/InputSystemUIInputModule.cs 0.00% 7 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2192      +/-   ##
===========================================
- Coverage    65.45%   65.45%   -0.01%     
===========================================
  Files          367      367              
  Lines        53505    53511       +6     
===========================================
- Hits         35024    35023       -1     
- Misses       18481    18488       +7     
Flag Coverage Δ
mac_2021.3_pkg 5.41% <0.00%> (-0.01%) ⬇️
mac_2021.3_project 70.40% <0.00%> (-0.02%) ⬇️
mac_2022.3_pkg 5.19% <ø> (ø)
mac_2022.3_project 65.28% <0.00%> (-0.02%) ⬇️
mac_6000.0_pkg 5.20% <ø> (ø)
mac_6000.0_project 65.37% <0.00%> (-0.02%) ⬇️
mac_6000.1_pkg 5.20% <ø> (ø)
mac_6000.1_project 65.36% <0.00%> (-0.01%) ⬇️
mac_6000.2_pkg 5.20% <ø> (ø)
mac_6000.2_project 65.36% <0.00%> (+<0.01%) ⬆️
mac_trunk_pkg 5.20% <ø> (ø)
mac_trunk_project 65.35% <0.00%> (-0.01%) ⬇️
win_2021.3_pkg 5.42% <0.00%> (-0.01%) ⬇️
win_2021.3_project 70.48% <0.00%> (-0.02%) ⬇️
win_2022.3_pkg 5.20% <ø> (ø)
win_2022.3_project 65.35% <0.00%> (-0.02%) ⬇️
win_6000.0_pkg 5.20% <ø> (ø)
win_6000.0_project 65.44% <0.00%> (-0.01%) ⬇️
win_6000.1_pkg 5.20% <ø> (ø)
win_6000.1_project 65.44% <0.00%> (-0.01%) ⬇️
win_6000.2_pkg 5.20% <ø> (ø)
win_6000.2_project 65.43% <0.00%> (-0.01%) ⬇️
win_trunk_pkg 5.20% <ø> (ø)
win_trunk_project 65.43% <0.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
...InputSystem/Plugins/UI/InputSystemUIInputModule.cs 93.15% <0.00%> (-0.61%) ⬇️
🚀 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 reset the default actions static field during scene load to fix it ha… FIX: disabling the InputSystemUIInputModule resets all actions to None Jun 5, 2025
@K-Tone K-Tone changed the title FIX: disabling the InputSystemUIInputModule resets all actions to None FIX: disabling the InputSystemUIInputModule component resets all actions to None Jun 5, 2025
@K-Tone K-Tone requested a review from Copilot June 6, 2025 09:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses an issue where disabling the InputSystemUIInputModule component inadvertently resets all actions, including user-configured ones, instead of just the default actions asset. Key changes include:

  • Adding a static ResetDefaultActions method that disposes the default actions asset on domain reload.
  • Removing the UnassignActions() call from OnDisable to prevent resetting user actions.
Comments suppressed due to low confidence (2)

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:1678

  • [nitpick] Removing 'UnassignActions()' is the intended change to prevent resetting user-assigned actions; consider adding an inline comment to clearly explain this design decision for future maintainers.
UnassignActions();

Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs:1532

  • [nitpick] While the ResetDefaultActions method properly disposes the default actions, adding a summary comment that explains its role during domain reloads would improve clarity and maintainability.
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]

@K-Tone
Copy link
Collaborator Author

K-Tone commented Jun 6, 2025

As to the catches by Copilot:

(1) This is fine. Historically, we've only had UnassignActions since the beginning of the year, and that was a mistake, so I think future maintainers don't need to know we made that mistake and corrected it quickly

(2) There is a short, but to the point comment actually. Not sure I'd like to expand it further.

@K-Tone K-Tone requested review from ekcoh and Pauliusd01 June 6, 2025 10:12
Copy link
Collaborator

@Pauliusd01 Pauliusd01 left a comment

Choose a reason for hiding this comment

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

Found an issue with the UI default actions getting added in after a scene load. Steps are: Open our main repo as a unity project -> top dropdown QA Tools -> Add all core samples / open core scene -> import the textmeshpro essentials if needed -> make sure the event system is set to use a project wide actions asset if it isn't already -> enter play mode and observe the action count -> pick anything from the scene loader -> esc -> return to scene picker and observe the action count again. This does not reproduce in Develop

06.06.2025.-.Unity.197.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants