@@ -68,10 +68,17 @@ private void OnGUI()
6868 if ( selectedTypes . Count == 0 || ! selectedTypes . Contains ( configGroup [ 0 ] . GetType ( ) ) )
6969 continue ;
7070
71- GUILayout . Space ( 15 ) ;
71+ GUILayout . Space ( 20 ) ;
7272
73+ EditorGUILayout . BeginHorizontal ( ) ;
7374 GUILayout . Label ( configGroup [ 0 ] . GetType ( ) . Name , EditorStyles . boldLabel ) ; // Display the type name as a section header
7475
76+ if ( GUILayout . Button ( "Add New" , GUILayout . Width ( 80 ) ) )
77+ {
78+ AddNewSO ( configGroup [ 0 ] . GetType ( ) ) ;
79+ }
80+
81+ EditorGUILayout . EndHorizontal ( ) ;
7582 EditorGUILayout . BeginHorizontal ( "box" ) ;
7683
7784 PutPropertiesForObject ( configGroup ) ;
@@ -82,6 +89,28 @@ private void OnGUI()
8289 EditorGUILayout . EndScrollView ( ) ;
8390 }
8491
92+ void AddNewSO ( Type type )
93+ {
94+ // Create a new instance of the selected ScriptableObject type
95+ ScriptableObject newConfig = ScriptableObject . CreateInstance ( type ) ;
96+
97+ // Save file panel that works within the project (Assets/)
98+ string path = EditorUtility . SaveFilePanelInProject (
99+ "Save Config" ,
100+ type . Name + ".asset" ,
101+ "asset" ,
102+ "Please enter a file name to save the ScriptableObject." ,
103+ "Assets/Resources/ScriptableObjects"
104+ ) ;
105+
106+ if ( ! string . IsNullOrEmpty ( path ) )
107+ {
108+ AssetDatabase . CreateAsset ( newConfig , path ) ;
109+ AssetDatabase . SaveAssets ( ) ;
110+ AssetDatabase . Refresh ( ) ;
111+ }
112+ }
113+
85114 private void LoadAvailableTypes ( )
86115 {
87116 // Scan the "ScriptableObjects" folder to find all unique ScriptableObject types
0 commit comments