-
Notifications
You must be signed in to change notification settings - Fork 333
CHANGE: Update asset InputSystem.inputsettings to use UI Toolkit framework #2393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
6c659ad
46264f4
4a7eb48
55b4cfa
4b8f6a6
57cb44e
2ecfd57
6df94dc
5149b51
794539a
a500b2b
2002822
cf79402
dd55623
ee7d111
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| using System; | ||
| using System.IO; | ||
| using UnityEditor; | ||
| using UnityEngine.UIElements; | ||
|
|
||
| namespace UnityEngine.InputSystem.Editor | ||
| { | ||
|
|
@@ -19,7 +20,7 @@ | |
| 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. | ||
|
josepmariapujol-unity marked this conversation as resolved.
|
||
| /// </summary> | ||
| Cancelled, | ||
|
|
||
|
|
@@ -82,12 +83,32 @@ | |
| 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>(Func<T> getCurrent, T target, string targetName, string entity, | ||
| Action<T> apply, Action<Action> subscribeToChanges, Action<Action> unsubscribeFromChanges, | ||
| bool allowAssignActive = true) | ||
| where T : ScriptableObject | ||
| { | ||
| var container = new VisualElement(); | ||
|
|
||
| void Refresh() => PopulateMakeActiveGui(container, getCurrent(), target, entity, apply, allowAssignActive); | ||
|
|
||
| Refresh(); | ||
|
|
||
| // Subscribe for as long as the element is part of a panel, matching the pattern used in InputParameterEditor. | ||
| container.RegisterCallback<AttachToPanelEvent>(_ => subscribeToChanges(Refresh)); | ||
| container.RegisterCallback<DetachFromPanelEvent>(_ => unsubscribeFromChanges(Refresh)); | ||
|
Check warning on line 99 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
|
|
||
| return container; | ||
| } | ||
|
Check warning on line 102 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
|
|
||
| private static void PopulateMakeActiveGui<T>(VisualElement container, T current, T target, string entity, Action<T> apply, bool allowAssignActive) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The previous IMGUI implementation re-evaluated Consider implementing a simple poll using 🤖 Helpful? 👍/👎 |
||
| where T : ScriptableObject | ||
| { | ||
| container.Clear(); | ||
|
Check warning on line 107 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
|
|
||
| if (current == target) | ||
| { | ||
| EditorGUILayout.HelpBox($"These actions are assigned as the {entity}.", MessageType.Info); | ||
| container.Add(new HelpBox($"These actions are assigned as the {entity}.", HelpBoxMessageType.Info)); | ||
|
josepmariapujol-unity marked this conversation as resolved.
|
||
| return; | ||
| } | ||
|
|
||
|
|
@@ -96,11 +117,21 @@ | |
| 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)) | ||
|
|
||
| container.Add(new HelpBox( | ||
|
josepmariapujol-unity marked this conversation as resolved.
|
||
| $"These actions are not assigned as the {entity} for the Input System. {currentlyActiveAssetsPath ?? ""}", | ||
|
josepmariapujol-unity marked this conversation as resolved.
|
||
| HelpBoxMessageType.Warning)); | ||
|
|
||
| var assignButton = new Button(() => | ||
| { | ||
|
Check warning on line 126 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
| apply(target); | ||
| GUI.enabled = true; | ||
| PopulateMakeActiveGui(container, target, target, entity, apply, allowAssignActive); | ||
| }) | ||
|
Check warning on line 129 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
| { | ||
| text = $"Assign as the {entity}" | ||
| }; | ||
| assignButton.SetEnabled(allowAssignActive); | ||
| container.Add(assignButton); | ||
|
Check warning on line 134 in Packages/com.unity.inputsystem/InputSystem/Editor/InputAssetEditorUtils.cs
|
||
| } | ||
|
|
||
| public static bool IsValidFileExtension(string path) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.