Skip to content

NEW: Icon to InputSystem settings asset#2400

Open
josepmariapujol-unity wants to merge 8 commits intodevelopfrom
input/settings-icon
Open

NEW: Icon to InputSystem settings asset#2400
josepmariapujol-unity wants to merge 8 commits intodevelopfrom
input/settings-icon

Conversation

@josepmariapujol-unity
Copy link
Copy Markdown
Collaborator

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

Description

Adding an icon to InputSystem settings asset InputSystem.inputsettings.

Icon library:
Screenshot 2026-03-27 at 18 33 54

Dark:
Screenshot 2026-03-27 at 18 27 09

Light:
Screenshot 2026-03-27 at 18 26 59

Testing status & QA

N/A

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: 0
  • Halo Effect: 0

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 Mar 27, 2026
@josepmariapujol-unity josepmariapujol-unity changed the title Input/settings icon ADDED: Icon to InputSystem settings asset Mar 27, 2026
@josepmariapujol-unity josepmariapujol-unity changed the title ADDED: Icon to InputSystem settings asset NEW: Icon to InputSystem settings asset Mar 27, 2026
@josepmariapujol-unity josepmariapujol-unity marked this pull request as ready for review March 27, 2026 17:38
Copy link
Copy Markdown
Contributor

@u-pr u-pr bot left a comment

Choose a reason for hiding this comment

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

Good
The pull request introduces improvements to the Input System's editor settings, specifically regarding icon management. However, there are a few architectural and performance issues identified, such as setting icons in OnEnable (which can cause VCS noise) and potential icon persistence issues when creating new assets.

🤖 Helpful? 👍/👎

Comment on lines +496 to +501
private void OnEnable()
{
var icon = InputActionAssetIconLoader.LoadSettingsIcon();
if (icon != null)
EditorGUIUtility.SetIconForObject(target, icon);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium
Calling EditorGUIUtility.SetIconForObject inside OnEnable of an Editor is an anti-pattern that can lead to several issues:

  1. Metadata Pollution: For assets, this method modifies the associated .meta file. Calling it in OnEnable ensures the metadata is potentially modified every time the asset is selected or the inspector is refreshed, causing unnecessary noise in Version Control Systems (e.g., Git, Perforce).
  2. Dirtying Assets: It may mark the asset as dirty, triggering "Save Changes" prompts or automatic saves when the user merely viewed the asset.
  3. Import Loops: In some Unity versions, modifying metadata can trigger an asset re-import, which might re-trigger OnEnable, potentially leading to a refresh loop.

It is recommended to set the icon once during asset creation or via an AssetPostprocessor rather than forcing it every time the inspector is enabled.

🤖 Helpful? 👍/👎

Comment on lines +214 to +218
var settings = ScriptableObject.CreateInstance<InputSettings>();
var icon = InputActionAssetIconLoader.LoadSettingsIcon();
if (icon != null)
EditorGUIUtility.SetIconForObject(settings, icon);
InputSystem.settings = InputAssetEditorUtils.CreateAsset(settings, relativePath);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium
Have you considered calling EditorGUIUtility.SetIconForObject after the asset is created via InputAssetEditorUtils.CreateAsset?

When SetIconForObject is called on a memory-only instance (created via ScriptableObject.CreateInstance), the icon association is often lost or not correctly persisted to the asset's metadata (.meta file) when it is subsequently saved to disk. To ensure the icon persists, it should be applied to the object once it has been registered as an asset in the AssetDatabase.

Suggested change
var settings = ScriptableObject.CreateInstance<InputSettings>();
var icon = InputActionAssetIconLoader.LoadSettingsIcon();
if (icon != null)
EditorGUIUtility.SetIconForObject(settings, icon);
InputSystem.settings = InputAssetEditorUtils.CreateAsset(settings, relativePath);
var settings = ScriptableObject.CreateInstance<InputSettings>();
var createdAsset = InputAssetEditorUtils.CreateAsset(settings, relativePath);
if (createdAsset != null)
{
var icon = InputActionAssetIconLoader.LoadSettingsIcon();
if (icon != null)
EditorGUIUtility.SetIconForObject(createdAsset, icon);
InputSystem.settings = createdAsset;
}

🤖 Helpful? 👍/👎

/// <returns>Icon resource reference or <code>null</code> if the resource could not be loaded.</returns>
internal static Texture2D LoadSettingsIcon()
{
return (Texture2D)EditorGUIUtility.Load(kSettingsIcon);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

low
Have you considered caching the loaded Texture2D in a static field? While EditorGUIUtility.Load performs some internal caching, maintaining a static reference in this loader class avoids the overhead of repeated lookups, which is beneficial since this method is called within OnEnable of the InputSettingsEditor.

🤖 Helpful? 👍/👎

@codecov-github-com
Copy link
Copy Markdown

codecov-github-com bot commented Mar 27, 2026

Codecov Report

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

Files with missing lines Patch % Lines
...putSystem/Editor/Settings/InputSettingsProvider.cs 0.00% 10 Missing ⚠️
...Editor/AssetImporter/InputActionAssetIconLoader.cs 0.00% 3 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2400      +/-   ##
===========================================
+ Coverage    77.92%   78.08%   +0.16%     
===========================================
  Files          482      483       +1     
  Lines        97755    98772    +1017     
===========================================
+ Hits         76175    77131     +956     
- Misses       21580    21641      +61     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.34% <0.00%> (-0.22%) ⬇️
inputsystem_MacOS_2022.3_project 75.28% <0.00%> (-0.08%) ⬇️
inputsystem_MacOS_6000.0 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.0_project 77.19% <0.00%> (-0.08%) ⬇️
inputsystem_MacOS_6000.3 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.3_project 77.18% <0.00%> (-0.09%) ⬇️
inputsystem_MacOS_6000.4 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_MacOS_6000.4_project 77.19% <0.00%> (-0.09%) ⬇️
inputsystem_MacOS_6000.5 5.30% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_6000.5_project 77.22% <0.00%> (-0.06%) ⬇️
inputsystem_MacOS_6000.6 5.30% <0.00%> (-0.04%) ⬇️
inputsystem_MacOS_6000.6_project 77.22% <0.00%> (-0.06%) ⬇️
inputsystem_Ubuntu_2022.3_project 75.18% <0.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_6000.0 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.0_project 77.09% <0.00%> (+0.02%) ⬆️
inputsystem_Ubuntu_6000.3 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.3_project 77.08% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.4 5.32% <0.00%> (-0.03%) ⬇️
inputsystem_Ubuntu_6000.4_project 77.09% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_6000.5 5.31% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.5_project 77.13% <0.00%> (+0.04%) ⬆️
inputsystem_Ubuntu_6000.6 5.31% <0.00%> (-0.04%) ⬇️
inputsystem_Ubuntu_6000.6_project 77.13% <0.00%> (+0.04%) ⬆️
inputsystem_Windows_2022.3 5.34% <0.00%> (-0.22%) ⬇️
inputsystem_Windows_2022.3_project 75.41% <0.00%> (-0.08%) ⬇️
inputsystem_Windows_6000.0 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.0_project 77.31% <0.00%> (-0.08%) ⬇️
inputsystem_Windows_6000.3 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.3_project 77.31% <0.00%> (-0.08%) ⬇️
inputsystem_Windows_6000.4 5.31% <0.00%> (-0.03%) ⬇️
inputsystem_Windows_6000.4_project 77.32% <0.00%> (-0.08%) ⬇️
inputsystem_Windows_6000.5 5.30% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.5_project 77.35% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.6 5.30% <0.00%> (-0.04%) ⬇️
inputsystem_Windows_6000.6_project 77.35% <0.00%> (-0.04%) ⬇️

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

Files with missing lines Coverage Δ
...Editor/AssetImporter/InputActionAssetIconLoader.cs 66.66% <0.00%> (-33.34%) ⬇️
...putSystem/Editor/Settings/InputSettingsProvider.cs 1.57% <0.00%> (-0.04%) ⬇️

... and 7 files with indirect coverage changes

ℹ️ Need help interpreting these results?

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