Skip to content

Commit 6c659ad

Browse files
Updating to UITOOLKIT input asset editor
1 parent 0bb75c4 commit 6c659ad

3 files changed

Lines changed: 32 additions & 17 deletions

File tree

Packages/com.unity.inputsystem/InputSystem/Editor/AssetImporter/InputActionImporterEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public override void OnInspectorGUI()
3939
EditorGUILayout.Space();
4040

4141
// Project-wide Input Actions Asset UI.
42-
InputAssetEditorUtils.DrawMakeActiveGui(InputSystem.actions, inputActionAsset,
42+
InputAssetEditorUtils.CreateMakeActiveGui(InputSystem.actions, inputActionAsset,
4343
inputActionAsset ? inputActionAsset.name : "Null", "Project-wide Input Actions",
4444
(value) => InputSystem.actions = value, !EditorApplication.isPlayingOrWillChangePlaymode);
4545

Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System;
44
using System.IO;
55
using UnityEditor;
6+
using UnityEngine.UIElements;
67

78
namespace UnityEngine.InputSystem.Editor
89
{
@@ -19,7 +20,7 @@ internal enum DialogResult
1920
InvalidPath,
2021

2122
/// <summary>
22-
/// The dialog was cancelled by the user and the path is invalid.
23+
/// The dialog was canceled by the user and the path is invalid.
2324
/// </summary>
2425
Cancelled,
2526

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

85-
public static void DrawMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
86+
public static VisualElement CreateMakeActiveGui<T>(T current, T target, string targetName, string entity, Action<T> apply, bool allowAssignActive = true)
8687
where T : ScriptableObject
8788
{
89+
var container = new VisualElement();
90+
8891
if (current == target)
8992
{
90-
EditorGUILayout.HelpBox($"These actions are assigned as the {entity}.", MessageType.Info);
91-
return;
93+
container.Add(new HelpBox($"These actions are assigned as the {entity}.", HelpBoxMessageType.Info));
94+
return container;
9295
}
9396

9497
string currentlyActiveAssetsPath = null;
9598
if (current != null)
9699
currentlyActiveAssetsPath = AssetDatabase.GetAssetPath(current);
97100
if (!string.IsNullOrEmpty(currentlyActiveAssetsPath))
98101
currentlyActiveAssetsPath = $" The actions currently assigned as the {entity} are: {currentlyActiveAssetsPath}. ";
99-
EditorGUILayout.HelpBox($"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath??""}", MessageType.Warning);
100-
GUI.enabled = allowAssignActive;
101-
if (GUILayout.Button($"Assign as the {entity}", EditorStyles.miniButton))
102-
apply(target);
103-
GUI.enabled = true;
102+
103+
container.Add(new HelpBox(
104+
$"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath ?? ""}",
105+
HelpBoxMessageType.Warning));
106+
107+
var assignButton = new Button(() => apply(target))
108+
{
109+
text = $"Assign as the {entity}"
110+
};
111+
assignButton.SetEnabled(allowAssignActive);
112+
container.Add(assignButton);
113+
114+
return container;
104115
}
105116

106117
public static bool IsValidFileExtension(string path)

Packages/com.unity.inputsystem/InputSystem/Editor/Settings/InputSettingsProvider.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -489,17 +489,21 @@ internal static void ForceReload()
489489
[CustomEditor(typeof(InputSettings))]
490490
internal class InputSettingsEditor : UnityEditor.Editor
491491
{
492-
public override void OnInspectorGUI()
492+
public override VisualElement CreateInspectorGUI()
493493
{
494-
EditorGUILayout.Space();
494+
var root = new VisualElement();
495495

496-
if (GUILayout.Button("Open Input Settings Window", GUILayout.Height(30)))
497-
InputSettingsProvider.Open();
496+
var openButton = new Button(() => InputSettingsProvider.Open())
497+
{
498+
text = "Open Input Settings Window",
499+
style = { height = 30 }
500+
};
501+
root.Add(openButton);
498502

499-
EditorGUILayout.Space();
503+
root.Add(InputAssetEditorUtils.CreateMakeActiveGui(InputSystem.settings, target as InputSettings,
504+
target.name, "settings", (value) => InputSystem.settings = value));
500505

501-
InputAssetEditorUtils.DrawMakeActiveGui(InputSystem.settings, target as InputSettings,
502-
target.name, "settings", (value) => InputSystem.settings = value);
506+
return root;
503507
}
504508

505509
protected override bool ShouldHideOpenButton()

0 commit comments

Comments
 (0)