InputSystem icon indicating copy to clipboard operation
InputSystem copied to clipboard

FIX: Custom processors serialises enum by index rather than by value.

Open AswinRajGopal opened this issue 7 months ago • 11 comments

Description

Bug: https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1474 Port 1.13.1

The issue is that the DropdownField expects a selected index (starting at 0), but the enum’s underlying values (10, 20, 30..) don't match these indices. Instead of passing the enum’s integer value directly, I have mapped the value to the correct index in the list of enum options.

An automated test added which validates that a custom input processor with an enumerated parameter integrates correctly with both the Unity Input System’s asset serialization and its UI.

The issue is that

Testing status & QA

Verified manually in windows machine with the provided repro project. Authored an automated test to cover the fix.

Observer details of the test run:

Overall Product Risks

  • Complexity: 0
  • Halo Effect: 0

Comments to reviewers

Checklist

Before review:

  • [x] 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 %<ID>%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • [x] 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.

AswinRajGopal avatar Apr 08 '25 08:04 AswinRajGopal

CLA assistant check
All committers have signed the CLA.

unity-cla-assistant avatar Apr 08 '25 08:04 unity-cla-assistant

@AswinRajGopal Its generally recommended to add one developer on the team and one QA as reviewers on the PR when published. This will help making sure you receive feedback on it.

Looks like there are CI failures for non-required tests and that branch is outdated. I would recommend updating the branch (which will automatically re-run CI).

ekcoh avatar Apr 22 '25 18:04 ekcoh

@AswinRajGopal I notice you have published internal URLs in this public-facing PR. This should be avoided. Instead use public URLs to issue tickets when available and otherwise only use issue number (without link). I will remove the URLs for now.

ekcoh avatar Apr 22 '25 18:04 ekcoh

One concern I noticed is that the enum field is blank after upgrading to the new version, requiring the user to repick and save. Real problem? Any way to fix it?

Hi @Pauliusd01 could you please give me the steps to repro this issue? which version should I upgrade? Thanks.

AswinRajGopal avatar May 01 '25 13:05 AswinRajGopal

One concern I noticed is that the enum field is blank after upgrading to the new version, requiring the user to repick and save. Real problem? Any way to fix it?

Hi @Pauliusd01 could you please give me the steps to repro this issue? which version should I upgrade? Thanks.

Your version. Steps are: Open the user project -> Upgrade the version to yours (package manager -> add from disk -> point to the version with your changes) -> observe the user's enum field is blank

Pauliusd01 avatar May 02 '25 06:05 Pauliusd01

Codecov Report

Attention: Patch coverage is 48.57143% with 36 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...nputsystem/InputSystem/Actions/InputActionAsset.cs 37.50% 35 Missing :warning:
...nputSystem/Editor/AssetEditor/ParameterListView.cs 92.85% 1 Missing :warning:
@@             Coverage Diff             @@
##           develop    #2164      +/-   ##
===========================================
+ Coverage    67.78%   68.11%   +0.32%     
===========================================
  Files          367      367              
  Lines        53538    53603      +65     
===========================================
+ Hits         36293    36513     +220     
+ Misses       17245    17090     -155     
Flag Coverage Δ
mac_2021.3_pkg 5.40% <0.00%> (-0.01%) :arrow_down:
mac_2021.3_project 70.38% <37.50%> (-0.04%) :arrow_down:
mac_2022.3_pkg 5.18% <0.00%> (-0.01%) :arrow_down:
mac_2022.3_project 65.24% <30.00%> (-0.05%) :arrow_down:
mac_6000.0_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
mac_6000.0_project 68.04% <48.57%> (+0.33%) :arrow_up:
mac_6000.1_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
mac_6000.1_project 68.04% <48.57%> (+0.33%) :arrow_up:
mac_6000.2_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
mac_6000.2_project 68.03% <48.57%> (+0.33%) :arrow_up:
mac_trunk_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
mac_trunk_project 68.03% <48.57%> (+0.33%) :arrow_up:
win_2021.3_pkg 5.41% <0.00%> (-0.01%) :arrow_down:
win_2021.3_project 70.45% <37.50%> (-0.04%) :arrow_down:
win_2022.3_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
win_2022.3_project 65.31% <30.00%> (-0.04%) :arrow_down:
win_6000.0_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
win_6000.0_project 68.11% <48.57%> (+0.33%) :arrow_up:
win_6000.1_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
win_6000.1_project 68.11% <48.57%> (+0.44%) :arrow_up:
win_6000.2_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
win_6000.2_project 68.11% <48.57%> (+0.33%) :arrow_up:
win_trunk_pkg 5.19% <0.00%> (-0.01%) :arrow_down:
win_trunk_project 68.11% <48.57%> (+0.33%) :arrow_up:

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

Files with missing lines Coverage Δ
...System/Editor/AssetImporter/InputActionImporter.cs 49.75% <ø> (ø)
...tSystem/Plugins/PlayerInput/DefaultInputActions.cs 26.76% <ø> (ø)
...nputSystem/Editor/AssetEditor/ParameterListView.cs 40.07% <92.85%> (+40.07%) :arrow_up:
...nputsystem/InputSystem/Actions/InputActionAsset.cs 74.08% <37.50%> (-7.54%) :arrow_down:

... and 9 files with indirect coverage changes

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

codecov-github-com[bot] avatar May 24 '25 17:05 codecov-github-com[bot]

I fixed the conflict and updated the branch based on develop. Hopefully CI rerun is all green now.

ekcoh avatar Jun 10 '25 15:06 ekcoh

The value is no longer blank after updating to the new version but it still different, is that expected? Example steps are: Open the user project -> observe that that the enum is set to Option D -> update the package to your version -> observe that the enum is set to Option A.

@Pauliusd01 I've uploaded the repro, it works for me, let me know if Im missing something here.

https://github.com/user-attachments/assets/7a395e33-f5a3-4dad-a14a-97560a48528a

AswinRajGopal avatar Jun 12 '25 15:06 AswinRajGopal

The value is no longer blank after updating to the new version but it still different, is that expected? Example steps are: Open the user project -> observe that that the enum is set to Option D -> update the package to your version -> observe that the enum is set to Option A.

@Pauliusd01 works for me again. this repro is loading a new extracted user project and upgrading the package. https://github.com/user-attachments/assets/43370f74-713e-4b3e-b9ee-39f1d636cdef

AswinRajGopal avatar Jun 12 '25 15:06 AswinRajGopal

Having the asset window already open might be what was different for you, try to close it while doing the repro steps. Bug's still there for me

13.06.2025.-.Unity.200.mp4

@Pauliusd01 it couldnt be the reason as the code changes regardless of window state, looks for the asset during its import time and perform the migration, it works for me here is the recording.

https://github.com/user-attachments/assets/0e3764d1-51dc-40ca-8127-2868e553b5b5

AswinRajGopal avatar Jun 13 '25 09:06 AswinRajGopal

Hi @ekcoh @LeoUnity All the yamato failures are because of regenerated DefaultInputActionAsset.cs. Please review. Thanks.

AswinRajGopal avatar Jun 18 '25 10:06 AswinRajGopal

I fixed the conflicts on this branch

ekcoh avatar Jun 25 '25 18:06 ekcoh