@@ -40,14 +40,27 @@ public static string[] BasicFilters
4040 private List < Type > selectedTypes = new ( ) ; // Tracks which ScriptableObject types are currently selected for display
4141 private List < Type > availableTypes = new ( ) ; // Holds all unique ScriptableObject types found in the project
4242
43- //textures:
43+ // textures:
4444 private Texture2D spaceIcon ;
4545 private Texture2D orientationIcon ;
4646 private Texture2D deleteConfigIcon ;
4747 private Texture2D addConfigIcon ;
4848 private Texture2D refreshIcon ;
4949 private Texture2D filtersIcon ;
5050
51+ // Buttons Styles:
52+ GUIContent spaceButton ;
53+ GUIContent orientationButton ;
54+ GUIContent refreshButton ;
55+ GUIContent filtersButton ;
56+ // create config button styles:
57+ GUIContent AddConfigButton ;
58+ GUILayoutOption [ ] AddConfigButtonOptions ;
59+ GUIStyle buttonStyle ;
60+
61+ // label styles:
62+ GUIStyle centeredLabelStyle ;
63+
5164 // window:
5265 [ MenuItem ( "Window/Game Config Editor" ) ]
5366 public static void ShowWindow ( )
@@ -76,13 +89,17 @@ private void OnEnable()
7689
7790 // Load icons for UI buttons
7891 LoadIcons ( ) ;
92+
93+ // setup styles
94+ SetupButtonStyles ( ) ;
7995 }
8096
81- private void OnGUI ( )
97+ /// <summary>
98+ /// Sets up the GUI buttons with their respective icons and tooltips.
99+ /// </summary>
100+ private void SetupButtonStyles ( )
82101 {
83- EditorGUILayout . BeginHorizontal ( ) ;
84-
85- GUIContent spaceButton ;
102+ // GUI content for space button
86103 if ( spaceIcon != null )
87104 {
88105 spaceButton = new GUIContent ( spaceIcon , "change space between parameters" ) ;
@@ -92,12 +109,7 @@ private void OnGUI()
92109 spaceButton = new GUIContent ( "space" , "change space between parameters" ) ;
93110 }
94111
95- if ( GUILayout . Button ( spaceButton , GUILayout . Width ( 50 ) ) )
96- {
97- SetSpace ( ) ;
98- }
99-
100- GUIContent orientationButton ;
112+ // GUI content for orientation button
101113 if ( orientationIcon != null )
102114 {
103115 orientationButton = new GUIContent ( orientationIcon , "change the table orientation" ) ;
@@ -107,6 +119,50 @@ private void OnGUI()
107119 orientationButton = new GUIContent ( "rotate" , "change the table orientation" ) ;
108120 }
109121
122+ // GUI content for refresh button
123+ if ( refreshIcon != null )
124+ {
125+ refreshButton = new GUIContent ( refreshIcon , "refresh" ) ;
126+ }
127+ else
128+ {
129+ refreshButton = new GUIContent ( "refresh" , "refresh" ) ;
130+ }
131+
132+ // GUI content for filters button
133+ if ( filtersIcon != null )
134+ {
135+ filtersButton = new GUIContent ( filtersIcon , "filters" ) ;
136+ }
137+ else
138+ {
139+ filtersButton = new GUIContent ( "filters" , "filters" ) ;
140+ }
141+
142+ // 'create config' button styles
143+ if ( addConfigIcon != null )
144+ {
145+ AddConfigButton = new GUIContent ( addConfigIcon , "create new config" ) ;
146+ AddConfigButtonOptions = new GUILayoutOption [ ] { GUILayout . Height ( 20 ) , GUILayout . Width ( 20 ) } ;
147+ }
148+ else
149+ {
150+ AddConfigButton = new GUIContent ( "Add new" , "create new config" ) ;
151+ AddConfigButtonOptions = new GUILayoutOption [ ] { GUILayout . Width ( 65 ) } ;
152+ }
153+ }
154+
155+ private void OnGUI ( )
156+ {
157+ EditorGUILayout . BeginHorizontal ( ) ;
158+
159+ // A button to set space between properties
160+ if ( GUILayout . Button ( spaceButton , GUILayout . Width ( 50 ) ) )
161+ {
162+ SetSpace ( ) ;
163+ }
164+
165+ // A button to change the orientation of the table
110166 if ( GUILayout . Button ( orientationButton , GUILayout . Width ( 50 ) ) )
111167 {
112168 if ( OrientationVertical )
@@ -123,30 +179,13 @@ private void OnGUI()
123179
124180 EditorGUILayout . Space ( ) ;
125181
126- GUIContent refreshButton ;
127- if ( refreshIcon != null )
128- {
129- refreshButton = new GUIContent ( refreshIcon , "refresh" ) ;
130- }
131- else
132- {
133- refreshButton = new GUIContent ( "refresh" , "refresh" ) ;
134- }
182+ // A button to refresh the list of ScriptableObjects
135183 if ( GUILayout . Button ( refreshButton , GUILayout . Width ( 50 ) ) )
136184 {
137185 RefreshAll ( ) ;
138186 }
139187
140- // Display a popup window at the mouse position for type selection
141- GUIContent filtersButton ;
142- if ( filtersIcon != null )
143- {
144- filtersButton = new GUIContent ( filtersIcon , "filters" ) ;
145- }
146- else
147- {
148- filtersButton = new GUIContent ( "filters" , "filters" ) ;
149- }
188+ // Display a popup window at the mouse position for basic filters
150189 if ( GUILayout . Button ( filtersButton , GUILayout . Width ( 50 ) ) )
151190 {
152191 Vector2 mousePosition = Event . current . mousePosition ;
@@ -156,32 +195,13 @@ private void OnGUI()
156195
157196 EditorGUILayout . Space ( 5 ) ;
158197
159- if ( selectedTypes == null || selectedTypes . Count == 0 || groupedConfigs == null || groupedConfigs . Count == 0 )
198+ // if there is no SO loaded or selected from filters show a message
199+ if ( selectedTypes == null || selectedTypes . Count == 0 || groupedConfigs == null || groupedConfigs . Count == 0 )
160200 {
161- EditorGUILayout . LabelField ( "Select a config from filters " , EditorStyles . boldLabel ) ;
201+ EditorGUILayout . LabelField ( "[No Config Selected] " , EditorStyles . boldLabel ) ;
162202 return ;
163203 }
164204
165-
166- // create config button styles:
167- GUIContent AddConfigButton ;
168- GUILayoutOption [ ] AddConfigButtonOptions ;
169- GUIStyle buttonStyle = new GUIStyle ( GUI . skin . button ) ;
170- if ( addConfigIcon != null )
171- {
172- AddConfigButton = new GUIContent ( addConfigIcon , "create new config" ) ;
173- AddConfigButtonOptions = new GUILayoutOption [ ] { GUILayout . Height ( 20 ) , GUILayout . Width ( 20 ) } ;
174-
175- buttonStyle . padding = new RectOffset ( 2 , 2 , 2 , 2 ) ;
176- buttonStyle . imagePosition = ImagePosition . ImageOnly ;
177- }
178- else
179- {
180- AddConfigButton = new GUIContent ( "Add new" , "create new config" ) ;
181- AddConfigButtonOptions = new GUILayoutOption [ ] { GUILayout . Width ( 65 ) } ;
182- }
183-
184-
185205 // show configs
186206 ScrollPosMain = EditorGUILayout . BeginScrollView ( ScrollPosMain ) ;
187207 if ( groupedConfigs . Count != 0 )
@@ -196,17 +216,23 @@ private void OnGUI()
196216
197217 EditorGUILayout . BeginHorizontal ( ) ;
198218
219+ // 'create config' button styles
220+ if ( addConfigIcon != null )
221+ {
222+ buttonStyle = new GUIStyle ( GUI . skin . button ) ;
223+ buttonStyle . padding = new RectOffset ( 2 , 2 , 2 , 2 ) ;
224+ buttonStyle . imagePosition = ImagePosition . ImageOnly ;
225+ }
226+
199227 // create config button:
200228 if ( GUILayout . Button ( AddConfigButton , buttonStyle , AddConfigButtonOptions ) )
201229 {
202230 AddNewSO ( configGroup [ 0 ] . GetType ( ) ) ;
203231 }
204232
205- // Özel stil oluþtur
206- GUIStyle centeredLabelStyle = new GUIStyle ( EditorStyles . boldLabel ) ;
207- centeredLabelStyle . fontSize = 16 ; // Font boyutunu ayarla
208-
209- // Etiketi bu stil ile görüntüle
233+ // show name of the ScriptableObject type
234+ centeredLabelStyle = new GUIStyle ( EditorStyles . boldLabel ) ;
235+ centeredLabelStyle . fontSize = 16 ;
210236 GUILayout . Label ( configGroup [ 0 ] . GetType ( ) . Name , centeredLabelStyle ) ;
211237
212238 EditorGUILayout . EndHorizontal ( ) ;
0 commit comments