Skip to content

Conversation

@josepmariapujol-unity
Copy link
Collaborator

@josepmariapujol-unity josepmariapujol-unity commented Jan 15, 2026

Description

Update usage of InstanceID to EntityId for some variables such as m_ActionAssetInstanceID within PlayerInputEditor.cs file.
Adding pragma warning as FindObjectsSortMode and Object.FindObject* methods that depend on InstanceID sort order are being deprecated in 6.4. (Following PR: https://github.cds.internal.unity3d.com/unity/unity/pull/89068)

JIRA: https://jira.unity3d.com/browse/UUM-132063

Testing status & QA

Only CI, for QA use latest 6.5 editor version and check if you can trigger the warning:
Screenshot 2026-01-13 at 14 02 15

Overall Product Risks

Please rate the potential complexity and halo effect from low to high for the reviewers. Note down potential risks to specific Editor branches if any.

  • Complexity: 2
  • Halo Effect: 2

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.

@josepmariapujol-unity josepmariapujol-unity self-assigned this Jan 15, 2026
@josepmariapujol-unity josepmariapujol-unity changed the title Update PlayerInputEditor.cs CHANGE: Update InstanceID to EntityId for PlayerInputEditor.cs Jan 15, 2026
@u-pr-agent
Copy link
Contributor

u-pr-agent bot commented Jan 15, 2026

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪

Small, localized conditional-compilation refactor, but needs careful validation across Unity version defines and null-asset scenarios.
🏅 Score: 81

The EntityId migration looks directionally correct, but there is a likely behavioral regression when no actions asset is assigned and some conditional logic/comments could be clarified.
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Behavior Regression

In the UNITY_6000_5_OR_NEWER path, m_ActionAssetEntityId is set to EntityId.None when the asset reference is null, and the inspector re-init condition includes m_ActionAssetEntityId == EntityId.None; this may cause InitializeEditorComponent(...) to run repeatedly (and potentially with a null asset) when no actions asset is assigned, unlike the previous m_ActionAssetInstanceID sentinel behavior.

#if UNITY_6000_5_OR_NEWER
            if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetEntityId == EntityId.None)
#else
            if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetInstanceID == 0)
#endif
            {
                InitializeEditorComponent(assetChanged);
                actionsWereChanged = true;
Null Asset Handling

CheckIfActionAssetChanged() now always resets m_ActionAssetEntityId to EntityId.None when the reference is null; verify downstream code does not interpret this as “needs initialization” on every GUI draw and that the editor state (m_ActionAssetInitialized, cached properties, etc.) is reset appropriately when the asset is cleared.

        bool CheckIfActionAssetChanged()
        {
            if (m_ActionsProperty.objectReferenceValue != null)
            {
#if UNITY_6000_5_OR_NEWER
                EntityId assetEntityId = m_ActionsProperty.objectReferenceValue.GetEntityId();
                bool result = assetEntityId != m_ActionAssetEntityId && m_ActionAssetEntityId != EntityId.None;
                m_ActionAssetEntityId = assetEntityId;
                return result;
            }

            m_ActionAssetEntityId = EntityId.None;
#else
                // 6.4 deprecates instance id in favour of entity ids (a class)
                // Fortunately, there is an implicit cast from entity id to an integer so we can have minimum footprint for now.
                int assetInstanceID;

                #if UNITY_6000_4_OR_NEWER
                assetInstanceID = m_ActionsProperty.objectReferenceValue.GetEntityId();
                #else
                assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
                #endif

                // if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
                bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
                m_ActionAssetInstanceID = (int)assetInstanceID;
                return result;
            }

            m_ActionAssetInstanceID = -1;
#endif

            return false;
        }
Maintainability

The comment about “6.4 deprecates instance id” and the mixed UNITY_6000_4_OR_NEWER/UNITY_6000_5_OR_NEWER logic can be confusing; consider aligning comments with the actual define branches and ensuring the EntityId vs int semantics remain consistent across versions.

// 6.4 deprecates instance id in favour of entity ids (a class)
// Fortunately, there is an implicit cast from entity id to an integer so we can have minimum footprint for now.
int assetInstanceID;

#if UNITY_6000_4_OR_NEWER
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetEntityId();
#else
assetInstanceID = m_ActionsProperty.objectReferenceValue.GetInstanceID();
#endif

// if the m_ActionAssetInstanceID is 0 the PlayerInputEditor has not been initialized yet, but the asset did not change
bool result = assetInstanceID != m_ActionAssetInstanceID && m_ActionAssetInstanceID != 0;
m_ActionAssetInstanceID = (int)assetInstanceID;
return result;
  • Update review

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

@u-pr-agent
Copy link
Contributor

u-pr-agent bot commented Jan 15, 2026

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Avoid reinitializing on empty asset

As written, m_ActionAssetEntityId is set to EntityId.None when no actions asset is
assigned, which makes this condition true every repaint and can repeatedly call
InitializeEditorComponent. Gate the EntityId.None check on having a non-null asset
(or remove it) to avoid unnecessary reinitialization when the field is empty.

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs [100-108]

 #if UNITY_6000_5_OR_NEWER
-            if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetEntityId == EntityId.None)
+            var hasActionAsset = m_ActionsProperty.objectReferenceValue != null;
+            if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || (hasActionAsset && m_ActionAssetEntityId == EntityId.None))
 #else
             if (EditorGUI.EndChangeCheck() || !m_ActionAssetInitialized || assetChanged || m_ActionAssetInstanceID == 0)
 #endif
             {
                 InitializeEditorComponent(assetChanged);
                 actionsWereChanged = true;
             }
Suggestion importance[1-10]: 8

__

Why: In the UNITY_6000_5_OR_NEWER branch, m_ActionAssetEntityId == EntityId.None will be true whenever the actions field is empty, causing InitializeEditorComponent to run every repaint even after m_ActionAssetInitialized is true. Gating this check on m_ActionsProperty.objectReferenceValue != null prevents unnecessary repeated initialization and potential side effects.

Medium
Detect asset clear as change

Clearing the actions asset (going from a valid id to null) currently returns false,
so assetChanged won't reflect this transition and any teardown/rebuild logic won't
run. Compute the current id as EntityId.None when null and compare against the
previous id so transitions both ways are treated as changes when initialized.

Packages/com.unity.inputsystem/InputSystem/Plugins/PlayerInput/PlayerInputEditor.cs [285-293]

 #if UNITY_6000_5_OR_NEWER
-            EntityId assetEntityId = m_ActionsProperty.objectReferenceValue.GetEntityId();
-            bool result = assetEntityId != m_ActionAssetEntityId && m_ActionAssetEntityId != EntityId.None;
-            m_ActionAssetEntityId = assetEntityId;
-            return result;
-        }
+        var previousEntityId = m_ActionAssetEntityId;
+        var currentEntityId = m_ActionsProperty.objectReferenceValue != null
+            ? m_ActionsProperty.objectReferenceValue.GetEntityId()
+            : EntityId.None;
 
-        m_ActionAssetEntityId = EntityId.None;
+        m_ActionAssetEntityId = currentEntityId;
+
+        // Treat transitions (set/clear/switch) as changes once initialized.
+        return m_ActionAssetInitialized && currentEntityId != previousEntityId;
 #else
Suggestion importance[1-10]: 7

__

Why: The current CheckIfActionAssetChanged returns false when the asset is cleared (non-null to null), so assetChanged won't reflect that transition and the editor may not rebuild/teardown correctly. Comparing the previous and current EntityId (using EntityId.None for null) fixes change detection for set/clear/switch once m_ActionAssetInitialized is true.

Medium
  • More suggestions

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

@codecov-github-com
Copy link

codecov-github-com bot commented Jan 15, 2026

Codecov Report

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

Files with missing lines Patch % Lines
...putSystem/Plugins/PlayerInput/PlayerInputEditor.cs 0.00% 12 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2325      +/-   ##
===========================================
- Coverage    77.95%   77.95%   -0.01%     
===========================================
  Files          476      476              
  Lines        97453    97465      +12     
===========================================
+ Hits         75971    75975       +4     
- Misses       21482    21490       +8     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.54% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2022.3_project 75.47% <0.00%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.36% <0.00%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.36% <0.00%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.37% <0.00%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.5 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.37% <0.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_2022.3 5.54% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_2022.3_project 75.27% <0.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.16% <0.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.16% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4 5.33% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.18% <0.00%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.5 5.33% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.18% <0.00%> (+<0.01%) ⬆️
inputsystem_Windows_2022.3 5.54% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3_project 75.60% <0.00%> (+<0.01%) ⬆️
inputsystem_Windows_6000.0 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.49% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.49% <0.00%> (+<0.01%) ⬆️
inputsystem_Windows_6000.4 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.50% <0.00%> (+<0.01%) ⬆️
inputsystem_Windows_6000.5 5.32% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.50% <0.00%> (+<0.01%) ⬆️

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

Files with missing lines Coverage Δ
...putSystem/Plugins/PlayerInput/PlayerInputEditor.cs 7.73% <0.00%> (-0.02%) ⬇️

... 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.

Copy link

@EmilieThaulow EmilieThaulow left a comment

Choose a reason for hiding this comment

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

LGTM

return result;
}

m_ActionAssetInstanceID = -1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why do we set -1 to m_ActionAssetInstanceID if it won't be 0 after m_ActionAssetEntityId = assetEntityId; (see above lines)

@Pauliusd01
Copy link
Collaborator

/test_plan

@u-pr-agent
Copy link
Contributor

u-pr-agent bot commented Jan 16, 2026

Test Plan

  • Test plan approved by PR author
  • Test execution in progress
  • Test execution complete
  • Ready for merge

Summary of Changes & Risk Assessment

Summary of Changes

This PR migrates the internal state tracking in PlayerInputEditor from InstanceID (int) to the new EntityId system introduced in Unity 6. It also suppresses deprecation warnings related to FindObjectsSortMode.InstanceID in editor utilities.

Risk Assessment

  • High Risk Areas: None identified.
  • Medium Risk Areas: Editor state initialization logic (ensuring InitializeEditorComponent isn't called every frame when the asset is null).
  • Low Risk Areas: Deprecation warning suppression in DumpInputActionReferences.cs.

Test Scenarios

Functional Testing

  • Asset Assignment: Assign an InputActionAsset to a PlayerInput component in Unity 6.5+. Verify the inspector initializes and displays action maps/events correctly.
  • Asset Swapping: Change the assigned InputActionAsset to a different one. Verify the inspector UI updates to reflect the new asset's actions.
  • Empty Asset State: Clear the Actions field. Verify the inspector displays the "Create Actions..." button and does not throw null reference exceptions.
  • Redundant Initialization Check: In Unity 6.5+, verify that InitializeEditorComponent is NOT called repeatedly every repaint when the Actions asset is null (referencing the logic change in PlayerInputEditor.cs:L101).

Regression Testing

  • Backward Compatibility (Unity < 6.5): Open the project in an older Unity version (e.g., 2022.3 LTS or 6000.0). Verify the #else block still uses m_ActionAssetInstanceID and the inspector remains functional.
  • Editor Tooling: Run the "Dump Input Action References" tool (via DumpInputActionReferences.cs). Verify it executes without errors and that the CS0618 warning is successfully suppressed.
  • Play Mode Persistence: Assign an asset, enter Play Mode, and exit. Verify the inspector state and the assigned EntityId remain stable.
🔍 Regression Deep Dive (additional risks identified)
  • Asset Clearing Detection: Verify that transitioning from a valid asset to null correctly triggers assetChanged or re-initialization. (Note: the current diff in CheckIfActionAssetChanged returns false if the reference is null, which might skip teardown logic).
  • Unity 6000.4 Implicit Cast: Specifically test on Unity 6000.4 where GetEntityId() is used but cast to an int PlayerInputEditor.cs:L298.

Edge Cases

  • Asset Deletion: Assign an asset, then delete the asset file from the Project window. Verify the PlayerInput inspector handles the missing reference gracefully.
  • Multi-Selection: Select multiple GameObjects with PlayerInput. Verify no errors occur when the assets differ between selection.

💡 This test plan updates automatically when /test_plan is run on new commits. If you have any feedback, please reach out in #ai-qa


🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

Copy link
Collaborator

@jfreire-unity jfreire-unity left a comment

Choose a reason for hiding this comment

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

Thanks for addressing these!

Pauliusd01

This comment was marked as off-topic.

@josepmariapujol-unity
Copy link
Collaborator Author

Getting this error on 6.4 (given it is an old editor 0a2, I can try updating if this sounds unrelated) image

Yes, please. Yet, I suspect this PR didn't touch file InputActionlmporter.cs. Could you try latest 6.4? TY!

@Pauliusd01 Pauliusd01 self-requested a review January 16, 2026 13:21
@josepmariapujol-unity
Copy link
Collaborator Author

@Pauliusd01 I've found the PR that made this changes to InputActionImporter.cs. However, since this is failing in alpha plus 6.4 is not LTS I wouldn't worry too much.

@Pauliusd01
Copy link
Collaborator

@Pauliusd01 I've found the PR that made this changes to InputActionImporter.cs. However, since this is failing in alpha plus 6.4 is not LTS I wouldn't worry too much.

Yeah it doesn't repro on 6.4 latest so just a false alarm from me

@josepmariapujol-unity
Copy link
Collaborator Author

@Pauliusd01 I've found the PR that made this changes to InputActionImporter.cs. However, since this is failing in alpha plus 6.4 is not LTS I wouldn't worry too much.

Yeah it doesn't repro on 6.4 latest so just a false alarm from me

Nice, else I assume CI would've picked it up :)

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.

5 participants