Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public override VisualElement CreateInspectorGUI()
"The currently selected object is not an editable input action asset.",
HelpBoxMessageType.Info));
}

var editButton = new Button(() => OpenEditor(inputActionAsset))
{
text = GetOpenEditorButtonText(inputActionAsset)
Expand Down Expand Up @@ -62,9 +61,7 @@ public override VisualElement CreateInspectorGUI()
private void BuildProjectWideSection(VisualElement container, InputActionAsset inputActionAsset)
{
container.Clear();

var currentActions = InputSystem.actions;
Comment thread
josepmariapujol-unity marked this conversation as resolved.

if (currentActions == inputActionAsset)
{
container.Add(new HelpBox(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.IO;
using UnityEditor;
using UnityEngine.UIElements;

namespace UnityEngine.InputSystem.Editor
{
Expand All @@ -19,7 +20,7 @@ internal enum DialogResult
InvalidPath,

/// <summary>
/// The dialog was cancelled by the user and the path is invalid.
/// The dialog was canceled by the user and the path is invalid.
Comment thread
josepmariapujol-unity marked this conversation as resolved.
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
The spelling in this comment was changed to 'canceled' (American English), but the corresponding enum member Cancelled (line 25) retains the British English spelling. To maintain consistency within the codebase, it is recommended to use the same spelling for both.

Suggested change
/// The dialog was canceled by the user and the path is invalid.
/// The dialog was cancelled by the user and the path is invalid.

🤖 Helpful? 👍/👎

/// </summary>
Cancelled,

Expand Down Expand Up @@ -82,25 +83,35 @@ internal static T CreateAsset<T>(T asset, string relativePath) where T : Scripta
return asset;
}

public static void DrawMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
public static VisualElement CreateMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
Comment thread
josepmariapujol-unity marked this conversation as resolved.
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
The targetName parameter is accepted by CreateMakeActiveGui but is not used within the method body or passed to PopulateMakeActiveGui. Since this is an internal utility class, consider removing it from the signature to simplify the API.

🤖 Helpful? 👍/👎

where T : ScriptableObject
{
var container = new VisualElement();

if (current == target)
{
EditorGUILayout.HelpBox($"These actions are assigned as the {entity}.", MessageType.Info);
return;
container.Add(new HelpBox($"These actions are assigned as the {entity}.", HelpBoxMessageType.Info));
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.

high
The HelpBox VisualElement was introduced in Unity 2021.1. If the Input System package is intended to support older Unity versions (such as 2019.4 or 2020.3 LTS), this change will introduce compilation errors. Have you verified the minimum supported Unity version for this PR? If older versions must be supported, consider using an IMGUIContainer with EditorGUILayout.HelpBox or a conditional compilation check.

🤖 Helpful? 👍/👎

return container;
}

string currentlyActiveAssetsPath = null;
if (current != null)
currentlyActiveAssetsPath = AssetDatabase.GetAssetPath(current);
if (!string.IsNullOrEmpty(currentlyActiveAssetsPath))
currentlyActiveAssetsPath = $" The actions currently assigned as the {entity} are: {currentlyActiveAssetsPath}. ";
EditorGUILayout.HelpBox($"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath??""}", MessageType.Warning);
GUI.enabled = allowAssignActive;
if (GUILayout.Button($"Assign as the {entity}", EditorStyles.miniButton))
apply(target);
GUI.enabled = true;

container.Add(new HelpBox(
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
For long asset paths, the HelpBox text might be clipped if it does not wrap. Consider setting the style's whiteSpace property to WhiteSpace.Normal to ensure the text wraps correctly, similar to the styling applied to the button in InputSettingsEditor.cs.

🤖 Helpful? 👍/👎

$"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath ?? ""}",
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
The current string construction in lines 109 and 112 results in redundant spaces in the displayed message (e.g., a double space after the first sentence and a trailing space at the end). Trimming these strings or adjusting the interpolation would provide a cleaner and more polished user interface.

🤖 Helpful? 👍/👎

HelpBoxMessageType.Warning));

var assignButton = new Button(() => apply(target))
Comment thread
josepmariapujol-unity marked this conversation as resolved.
Outdated
{
text = $"Assign as the {entity}"
};
assignButton.SetEnabled(allowAssignActive);
container.Add(assignButton);

return container;
}

public static bool IsValidFileExtension(string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,17 +489,21 @@ internal static void ForceReload()
[CustomEditor(typeof(InputSettings))]
internal class InputSettingsEditor : UnityEditor.Editor
{
public override void OnInspectorGUI()
public override VisualElement CreateInspectorGUI()
{
EditorGUILayout.Space();
var root = new VisualElement();

if (GUILayout.Button("Open Input Settings Window", GUILayout.Height(30)))
InputSettingsProvider.Open();
var openButton = new Button(() => InputSettingsProvider.Open())
{
text = "Open Input Settings Window",
style = { height = 30 }
};
root.Add(openButton);

EditorGUILayout.Space();
root.Add(InputAssetEditorUtils.CreateMakeActiveGui(InputSystem.settings, target as InputSettings,
target.name, "settings", (value) => InputSystem.settings = value));

InputAssetEditorUtils.DrawMakeActiveGui(InputSystem.settings, target as InputSettings,
target.name, "settings", (value) => InputSystem.settings = value);
return root;
}

protected override bool ShouldHideOpenButton()
Expand Down
Loading