33using System ;
44using System . IO ;
55using UnityEditor ;
6+ using UnityEngine . UIElements ;
67
78namespace 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 )
0 commit comments