Skip to content

FIX: Project-wide Input Actions are saved/auto-saved in the Project Settings window#2362

Draft
josepmariapujol-unity wants to merge 13 commits intodevelopfrom
input/save-asset-input-system
Draft

FIX: Project-wide Input Actions are saved/auto-saved in the Project Settings window#2362
josepmariapujol-unity wants to merge 13 commits intodevelopfrom
input/save-asset-input-system

Conversation

@josepmariapujol-unity
Copy link
Collaborator

@josepmariapujol-unity josepmariapujol-unity commented Feb 26, 2026

Description

This PR fixes the problem of input system actions not being saved when ProjectSettings window is opened together with InputSystem Actions window.

See post on forums

JIRA: UUM-134035

Screen.Recording.2026-02-26.at.14.40.29.mov

Testing status & QA

Double-check what is shown in the video making sure Save Asset/Auto-Save works.

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: 4

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 Feb 26, 2026
@josepmariapujol-unity josepmariapujol-unity marked this pull request as ready for review February 26, 2026 13:52
@u-pr
Copy link
Contributor

u-pr bot commented Feb 26, 2026

PR Reviewer Guide 🔍

(Review updated until commit 7e2617c)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

UUM-134035 - PR Code Verified

Compliant requirements:

  • Saving/auto-saving is now wired into the Project Settings Input Actions editor flow.

Requires further human verification:

  • Verify that closing the Project Settings window after creating a new Action Map persists it as a sub-asset in the Input Actions asset (the original repro steps).
  • Verify auto-save vs explicit save behaviors in the Project Settings window (including any UI buttons/toggles) work as intended and don’t regress the standalone editor workflow.
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪

The change is small but touches save semantics and project-wide asset verification, so it needs careful validation across multiple editor flows.

🏅 Score: 84

The fix looks directionally correct and improves reuse via a shared Save helper, but it introduces a few null-safety and lifecycle edge cases that should be hardened and validated.

🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Null Safety

Save(string path, InputActionAsset asset) calls asset.ToJson() and passes asset into ProjectWideActionsAsset.Verify(asset) without guarding for asset == null; if GetEditedAsset() can be null (e.g., during teardown/window close timing), this can throw and prevent saving.

internal static bool Save(string path, InputActionAsset asset)
{
    var projectWideActions = InputSystem.actions;
    if (projectWideActions != null && path == AssetDatabase.GetAssetPath(projectWideActions))
        ProjectWideActionsAsset.Verify(asset);

    return InputActionAssetManager.SaveAsset(path, asset.ToJson());
}
Callback Lifetime

The save callback captures asset and recomputes its path at invocation time; confirm asset is still valid (not disposed/unloaded) when invoked (e.g., on close/auto-save), otherwise saving may fail silently or throw.

m_View = new InputActionsEditorView(m_RootVisualElement, m_StateContainer, true, () => InputActionsEditorWindow.Save(AssetDatabase.GetAssetPath(asset), asset));

m_StateContainer.Initialize(m_RootVisualElement.Q("action-editor"));
Path Validation

Save(bool) resolves path from m_AssetGUID and now delegates to Save(path, asset); ensure behavior is well-defined when path is empty/invalid (e.g., asset moved/deleted) so TryUpdateFromAsset() and analytics aren’t executed under inconsistent states.

private void Save(bool isAutoSave)
{
    var path = AssetDatabase.GUIDToAssetPath(m_AssetGUID);
    var asset = GetEditedAsset();

    if (Save(path, asset))
        TryUpdateFromAsset();
  • Update review

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

@u-pr
Copy link
Contributor

u-pr bot commented Feb 26, 2026

PR Code Suggestions ✨

Latest suggestions up to 7e2617c
Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Guard against null path/asset

Add guards for asset == null and string.IsNullOrEmpty(path) to avoid
NullReferenceException (e.g., when the asset is deleted/unloaded while the UI is
open). Also avoid calling AssetDatabase.GetAssetPath in the comparison when path is
null/empty and compare using StringComparison.Ordinal for consistent behavior.

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorWindow.cs [295-302]

 internal static bool Save(string path, InputActionAsset asset)
 {
+    if (string.IsNullOrEmpty(path) || asset == null)
+        return false;
+
     var projectWideActions = InputSystem.actions;
-    if (projectWideActions != null && path == AssetDatabase.GetAssetPath(projectWideActions))
+    var projectWidePath = projectWideActions != null ? AssetDatabase.GetAssetPath(projectWideActions) : null;
+    if (!string.IsNullOrEmpty(projectWidePath) && string.Equals(path, projectWidePath, StringComparison.Ordinal))
         ProjectWideActionsAsset.Verify(asset);
 
     return InputActionAssetManager.SaveAsset(path, asset.ToJson());
 }
Suggestion importance[1-10]: 6

__

Why: The suggestion adds necessary null guards for asset and path in the internal static Save method. This prevents a potential NullReferenceException when calling asset.ToJson() and improves the method's robustness for general usage.

Low
  • More suggestions

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


Previous suggestions

Suggestions up to commit 826e5a2
CategorySuggestion                                                                                                                                    Impact
Possible issue
Allow manual saves unconditionally

The control-schemes view guard makes sense for auto-save (focus-stealing), but it
will also block an explicit user-initiated save. Remove the
IsControlSchemeViewActive() early return here so the user can always save from the
toolbar.

Packages/com.unity.inputsystem/InputSystem/Editor/UITKAssetEditor/InputActionsEditorSettingsProvider.cs [190-199]

 private void OnSaveAssetRequested()
 {
     var asset = GetAsset();
     if (asset == null)
         return;
-    if (m_View != null && m_View.IsControlSchemeViewActive())
-        return;
+
     ProjectWideActionsAsset.Verify(asset);
     EditorHelpers.SaveAsset(AssetDatabase.GetAssetPath(asset), asset.ToJson());
 }
Suggestion importance[1-10]: 7

__

Why: The m_View.IsControlSchemeViewActive() check is a workaround for ImGUI focus issues during auto-save. Including it in OnSaveAssetRequested (triggered by a manual user action) can lead to a confusing UX where the Save button click is ignored without any feedback.

Medium

@josepmariapujol-unity josepmariapujol-unity marked this pull request as draft February 26, 2026 13:55
@josepmariapujol-unity josepmariapujol-unity changed the title Input/save asset input system FIX: Input/save asset input system Mar 3, 2026
@josepmariapujol-unity josepmariapujol-unity changed the title FIX: Input/save asset input system FIX: Project-wide Input Actions are not auto-saved when closing the Project Settings window Mar 3, 2026
@josepmariapujol-unity josepmariapujol-unity changed the title FIX: Project-wide Input Actions are not auto-saved when closing the Project Settings window FIX: Project-wide Input Actions are saved/auto-saved in the Project Settings window Mar 3, 2026
@josepmariapujol-unity josepmariapujol-unity marked this pull request as ready for review March 3, 2026 12:49
@u-pr
Copy link
Contributor

u-pr bot commented Mar 3, 2026

Persistent review updated to latest commit 7e2617c

@codecov-github-com
Copy link

codecov-github-com bot commented Mar 3, 2026

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...KAssetEditor/InputActionsEditorSettingsProvider.cs 0.00% 1 Missing ⚠️
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 87.50% 1 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2362      +/-   ##
===========================================
- Coverage    77.90%   77.89%   -0.02%     
===========================================
  Files          476      476              
  Lines        97613    97635      +22     
===========================================
+ Hits         76048    76053       +5     
- Misses       21565    21582      +17     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.52% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_2022.3_project 75.39% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 77.29% <77.77%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.3 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 77.29% <77.77%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 77.30% <77.77%> (+<0.01%) ⬆️
inputsystem_MacOS_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.5_project 77.29% <77.77%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.6_project 77.29% <77.77%> (-0.01%) ⬇️
inputsystem_Ubuntu_2022.3_project 75.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.09% <77.77%> (+<0.01%) ⬆️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.09% <77.77%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.10% <77.77%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.10% <77.77%> (-0.02%) ⬇️
inputsystem_Ubuntu_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.10% <77.77%> (-0.01%) ⬇️
inputsystem_Windows_2022.3 5.52% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_2022.3_project 75.52% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 77.42% <77.77%> (+<0.01%) ⬆️
inputsystem_Windows_6000.3 5.30% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 77.42% <77.77%> (-0.01%) ⬇️
inputsystem_Windows_6000.4 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 77.42% <77.77%> (-0.01%) ⬇️
inputsystem_Windows_6000.5 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.5_project 77.43% <77.77%> (+<0.01%) ⬆️
inputsystem_Windows_6000.6 5.31% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.6_project 77.43% <77.77%> (+<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% <0.00%> (ø)
...Editor/UITKAssetEditor/InputActionsEditorWindow.cs 55.06% <87.50%> (+0.41%) ⬆️

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

@josepmariapujol-unity
Copy link
Collaborator Author

This could be probably the wrong approach, since I have just realized that it is a regression from PR

@josepmariapujol-unity josepmariapujol-unity marked this pull request as draft March 3, 2026 15:14
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.

1 participant