Skip to content

Input/save asset input system#2362

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

Input/save asset input system#2362
josepmariapujol-unity wants to merge 5 commits intodevelopfrom
input/save-asset-input-system

Conversation

@josepmariapujol-unity
Copy link
Collaborator

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

Description

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 🔍

Here are some key observations to aid the review process:

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

Small, localized change adding a save callback and a couple of fields, but it needs a quick behavior/UX sanity check across editor states.

🏅 Score: 86

Change is straightforward and likely correct, but introduces duplicated save logic and an unused field that should be validated/cleaned up before merging.

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

Behavior Consistency

The new save path duplicates the existing save logic but with different gating (it does not check InputEditorUserSettings.autoSaveInputActionAssets), so confirm this is intended (manual save vs autosave) and consider reusing a shared save helper to avoid future divergence.

private void ValidateAndSaveAsset(InputActionAsset asset)
{
    // This code should be cleaned up once we migrate the InputControl stuff from ImGUI completely.
    // Since at that point it stops being a separate window that steals focus.
    // (See case ISXB-1713)
    if (!InputEditorUserSettings.autoSaveInputActionAssets || m_View.IsControlSchemeViewActive())
    {
        return;
    }

    ProjectWideActionsAsset.Verify(asset);     // Ignore verification result for save
    EditorHelpers.SaveAsset(AssetDatabase.GetAssetPath(asset), asset.ToJson());
}

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());
}
Null/Path Handling

EditorHelpers.SaveAsset(AssetDatabase.GetAssetPath(asset), ...) assumes a valid asset path; if GetAsset() can ever return a non-persisted/in-memory asset, ensure the save call handles empty/invalid paths gracefully (or guard with string.IsNullOrEmpty).

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());
}
Dead Code

The new m_IsProjectSettings field is assigned but not used in the shown diff; if it’s not used elsewhere, it should be removed to avoid confusion (or used to control whether the save UI is available/visible).

private readonly Action m_SaveAction;
private readonly bool m_IsProjectSettings;

private ControlSchemesView m_ControlSchemesView;

public InputActionsEditorView(VisualElement root, StateContainer stateContainer, bool isProjectSettings,
                              Action saveAction)
    : base(root, stateContainer)
{
    m_SaveAction = saveAction;
    m_IsProjectSettings = isProjectSettings;
  • 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 ✨

Explore these optional code suggestions:

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
  • More suggestions

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

@josepmariapujol-unity josepmariapujol-unity marked this pull request as draft February 26, 2026 13:55
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