@@ -40,14 +40,27 @@ public static string[] BasicFilters
40
40
private List < Type > selectedTypes = new ( ) ; // Tracks which ScriptableObject types are currently selected for display
41
41
private List < Type > availableTypes = new ( ) ; // Holds all unique ScriptableObject types found in the project
42
42
43
- //textures:
43
+ // textures:
44
44
private Texture2D spaceIcon ;
45
45
private Texture2D orientationIcon ;
46
46
private Texture2D deleteConfigIcon ;
47
47
private Texture2D addConfigIcon ;
48
48
private Texture2D refreshIcon ;
49
49
private Texture2D filtersIcon ;
50
50
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
+
51
64
// window:
52
65
[ MenuItem ( "Window/Game Config Editor" ) ]
53
66
public static void ShowWindow ( )
@@ -76,13 +89,17 @@ private void OnEnable()
76
89
77
90
// Load icons for UI buttons
78
91
LoadIcons ( ) ;
92
+
93
+ // setup styles
94
+ SetupButtonStyles ( ) ;
79
95
}
80
96
81
- private void OnGUI ( )
97
+ /// <summary>
98
+ /// Sets up the GUI buttons with their respective icons and tooltips.
99
+ /// </summary>
100
+ private void SetupButtonStyles ( )
82
101
{
83
- EditorGUILayout . BeginHorizontal ( ) ;
84
-
85
- GUIContent spaceButton ;
102
+ // GUI content for space button
86
103
if ( spaceIcon != null )
87
104
{
88
105
spaceButton = new GUIContent ( spaceIcon , "change space between parameters" ) ;
@@ -92,12 +109,7 @@ private void OnGUI()
92
109
spaceButton = new GUIContent ( "space" , "change space between parameters" ) ;
93
110
}
94
111
95
- if ( GUILayout . Button ( spaceButton , GUILayout . Width ( 50 ) ) )
96
- {
97
- SetSpace ( ) ;
98
- }
99
-
100
- GUIContent orientationButton ;
112
+ // GUI content for orientation button
101
113
if ( orientationIcon != null )
102
114
{
103
115
orientationButton = new GUIContent ( orientationIcon , "change the table orientation" ) ;
@@ -107,6 +119,50 @@ private void OnGUI()
107
119
orientationButton = new GUIContent ( "rotate" , "change the table orientation" ) ;
108
120
}
109
121
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
110
166
if ( GUILayout . Button ( orientationButton , GUILayout . Width ( 50 ) ) )
111
167
{
112
168
if ( OrientationVertical )
@@ -123,30 +179,13 @@ private void OnGUI()
123
179
124
180
EditorGUILayout . Space ( ) ;
125
181
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
135
183
if ( GUILayout . Button ( refreshButton , GUILayout . Width ( 50 ) ) )
136
184
{
137
185
RefreshAll ( ) ;
138
186
}
139
187
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
150
189
if ( GUILayout . Button ( filtersButton , GUILayout . Width ( 50 ) ) )
151
190
{
152
191
Vector2 mousePosition = Event . current . mousePosition ;
@@ -156,32 +195,13 @@ private void OnGUI()
156
195
157
196
EditorGUILayout . Space ( 5 ) ;
158
197
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 )
160
200
{
161
- EditorGUILayout . LabelField ( "Select a config from filters " , EditorStyles . boldLabel ) ;
201
+ EditorGUILayout . LabelField ( "[No Config Selected] " , EditorStyles . boldLabel ) ;
162
202
return ;
163
203
}
164
204
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
-
185
205
// show configs
186
206
ScrollPosMain = EditorGUILayout . BeginScrollView ( ScrollPosMain ) ;
187
207
if ( groupedConfigs . Count != 0 )
@@ -196,17 +216,23 @@ private void OnGUI()
196
216
197
217
EditorGUILayout . BeginHorizontal ( ) ;
198
218
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
+
199
227
// create config button:
200
228
if ( GUILayout . Button ( AddConfigButton , buttonStyle , AddConfigButtonOptions ) )
201
229
{
202
230
AddNewSO ( configGroup [ 0 ] . GetType ( ) ) ;
203
231
}
204
232
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 ;
210
236
GUILayout . Label ( configGroup [ 0 ] . GetType ( ) . Name , centeredLabelStyle ) ;
211
237
212
238
EditorGUILayout . EndHorizontal ( ) ;
0 commit comments