@@ -84,11 +84,11 @@ public static IDisposable BackgroundColorScope(Color color)
84
84
85
85
public static void HeaderLogo ( float windowWidth )
86
86
{
87
- EditorGUILayout . Space ( 6f ) ;
87
+ EditorGUILayout . Space ( 25f ) ;
88
88
89
89
var logoTexture = ( Texture2D ) AssetDatabase . LoadAssetAtPath (
90
90
PlateauToolkitPaths . PlateauLogo , typeof ( Texture2D ) ) ;
91
- float width = Mathf . Min ( windowWidth - 20 , 260f ) ;
91
+ float width = Mathf . Min ( windowWidth - 20 , 170f ) ;
92
92
float height = ( float ) logoTexture . height / logoTexture . width * width ;
93
93
94
94
using ( new EditorGUILayout . HorizontalScope ( ) )
@@ -99,7 +99,7 @@ public static void HeaderLogo(float windowWidth)
99
99
GUILayout . FlexibleSpace ( ) ;
100
100
}
101
101
102
- EditorGUILayout . Space ( 10f ) ;
102
+ EditorGUILayout . Space ( 15f ) ;
103
103
}
104
104
105
105
public static void BorderLine ( )
@@ -108,52 +108,98 @@ public static void BorderLine()
108
108
EditorGUI . DrawRect ( borderRect , PlateauToolkitGUIStyles . k_LineColor ) ;
109
109
}
110
110
111
- public static void Header ( string label )
111
+ public static void Title ( float windowWidth , string label )
112
112
{
113
- EditorGUILayout . Space ( 8 ) ;
113
+ EditorGUILayout . Space ( 15 ) ;
114
114
115
- BorderLine ( ) ;
115
+ float imageWidth = 40f ;
116
+ float imageHeight = 1f ;
117
+ float imageOffset = 3f ;
118
+ float textWidth = 120f ;
119
+ float textHeight = 17f ;
120
+
121
+ Texture2D titleImage = AssetDatabase . LoadAssetAtPath < Texture2D > ( PlateauToolkitPaths . PlateauTitleBackground ) ;
122
+ Rect imageRect = EditorGUILayout . GetControlRect ( GUILayout . Width ( imageWidth ) , GUILayout . Height ( imageHeight ) ) ;
123
+ imageRect . y += ( textHeight / 2 ) + imageOffset ;
116
124
117
- using ( var scope = new EditorGUILayout . VerticalScope ( PlateauToolkitGUIStyles . HeaderBoxStyle , GUILayout . Height ( 24 ) ) )
125
+ using ( new EditorGUILayout . HorizontalScope ( GUILayout . Height ( textHeight ) ) )
118
126
{
119
- EditorGUI . DrawRect ( scope . rect , PlateauToolkitGUIStyles . k_HeaderBackgroundColor ) ;
127
+ GUILayout . FlexibleSpace ( ) ;
128
+
129
+ imageRect . x = ( windowWidth / 2 ) - ( textWidth / 2 ) - imageWidth ;
130
+ GUI . DrawTexture ( imageRect , titleImage ) ;
120
131
132
+ EditorGUILayout . LabelField ( label ,
133
+ PlateauToolkitGUIStyles . TitleTextStyle ,
134
+ GUILayout . Height ( textHeight ) ,
135
+ GUILayout . Width ( textWidth ) ) ;
136
+
137
+ imageRect . x = ( windowWidth / 2 ) + ( textWidth / 2 ) ;
138
+
139
+ // Draw the image upside down
140
+ GUIUtility . RotateAroundPivot ( 180f , imageRect . center ) ;
141
+ GUI . DrawTexture ( imageRect , titleImage ) ;
142
+ GUI . matrix = Matrix4x4 . identity ;
143
+
144
+ GUILayout . FlexibleSpace ( ) ;
145
+ }
146
+ }
147
+
148
+ public static void Header ( string label , int topMargin = 15 , int bottomMargin = 15 )
149
+ {
150
+ EditorGUILayout . Space ( topMargin ) ;
151
+
152
+ BorderLine ( ) ;
153
+ using ( var scope = new EditorGUILayout . VerticalScope ( PlateauToolkitGUIStyles . HeaderBoxStyle , GUILayout . Height ( 28 ) ) )
154
+ {
121
155
GUILayout . FlexibleSpace ( ) ;
122
156
using ( new EditorGUILayout . HorizontalScope ( PlateauToolkitGUIStyles . HeaderContentStyle ) )
123
157
{
124
- GUILayout . FlexibleSpace ( ) ;
125
- GUILayout . Label ( label , GUILayout . ExpandWidth ( false ) ) ;
158
+ EditorGUI . DrawRect ( scope . rect , PlateauToolkitGUIStyles . k_HeaderBackgroundColor ) ;
159
+ GUILayout . Label ( label , PlateauToolkitGUIStyles . HeaderTextStyle , GUILayout . ExpandWidth ( false ) ) ;
126
160
GUILayout . FlexibleSpace ( ) ;
127
161
}
128
162
GUILayout . FlexibleSpace ( ) ;
129
163
}
130
164
131
- BorderLine ( ) ;
165
+ EditorGUILayout . Space ( bottomMargin ) ;
166
+ }
132
167
133
- EditorGUILayout . Space ( 8 ) ;
168
+ public static EditorGUILayout . HorizontalScope TabScope ( float width )
169
+ {
170
+ var scope = new EditorGUILayout . HorizontalScope ( PlateauToolkitGUIStyles . TabBoxStyle ,
171
+ GUILayout . Height ( 64 ) ) ;
172
+ GUILayoutUtility . GetRect ( width , 64 ) ;
173
+ return scope ;
134
174
}
135
175
136
176
public static EditorGUILayout . VerticalScope FooterScope ( )
137
177
{
138
- BorderLine ( ) ;
139
-
140
- var scope = new EditorGUILayout . VerticalScope ( PlateauToolkitGUIStyles . FooterBoxStyle , GUILayout . Height ( 24 ) ) ;
141
- EditorGUI . DrawRect ( scope . rect , PlateauToolkitGUIStyles . k_FooterBackgroundColor ) ;
142
-
178
+ var scope = new EditorGUILayout . VerticalScope ( GUILayout . Height ( 24 ) ) ;
143
179
return scope ;
144
180
}
145
181
}
146
182
147
183
public static class PlateauToolkitGUIStyles
148
184
{
149
- public static readonly Color k_LineColor = new Color ( 40 / 255f , 40 / 255f , 40 / 255f , 1 ) ;
150
- public static readonly Color k_HeaderBackgroundColor = new Color ( 51 / 255f , 51 / 255f , 51 / 255f , 1 ) ;
185
+ public static readonly Color k_LineColor = new Color ( 33 / 255f , 33 / 255f , 33 / 255f , 1 ) ;
186
+ public static readonly Color k_HeaderBackgroundColor = new Color ( 62 / 255f , 62 / 255f , 62 / 255f , 1 ) ;
151
187
public static readonly Color k_FooterBackgroundColor = new Color ( 51 / 255f , 51 / 255f , 51 / 255f , 1 ) ;
188
+ public static readonly Color k_TabBackgroundColor = new Color ( 0 , 0 , 0 , 0.5f ) ;
189
+ public static readonly Color k_TabActiveColor = new Color ( 88 / 255f , 88 / 255f , 88 / 255f , 1 ) ;
190
+ public static readonly Color k_ButtonNormalColor = new Color ( 103 / 255f , 103 / 255f , 103 / 255f , 1 ) ;
191
+ public static readonly Color k_ButtonPrimaryColor = new Color ( 0 , 88 / 255f , 88 / 255f , 1 ) ;
192
+ public static readonly Color k_ButtonDisableColor = new Color ( 0 , 88 / 255f , 88 / 255f , 0.25f ) ;
193
+ public static readonly Color k_ButtonCancelColor = new Color ( 183 / 255f , 0 , 0 , 0.25f ) ;
152
194
153
195
public static GUIStyle BorderStyle { get ; }
154
196
public static GUIStyle HeaderBoxStyle { get ; }
155
197
public static GUIStyle HeaderContentStyle { get ; }
156
198
public static GUIStyle FooterBoxStyle { get ; }
199
+ public static GUIStyle TabBoxStyle { get ; }
200
+ public static GUIStyle ButtonStyle { get ; }
201
+ public static GUIStyle TitleTextStyle { get ; }
202
+ public static GUIStyle HeaderTextStyle { get ; }
157
203
158
204
static PlateauToolkitGUIStyles ( )
159
205
{
@@ -173,47 +219,136 @@ static PlateauToolkitGUIStyles()
173
219
174
220
HeaderContentStyle = new GUIStyle ( GUI . skin . box ) ;
175
221
HeaderContentStyle . normal . textColor = Color . white ;
176
- HeaderContentStyle . alignment = TextAnchor . MiddleCenter ;
222
+ HeaderContentStyle . alignment = TextAnchor . MiddleLeft ;
177
223
HeaderContentStyle . margin = new RectOffset ( 0 , 0 , 0 , 0 ) ;
178
- HeaderContentStyle . padding = new RectOffset ( 5 , 5 , 5 , 5 ) ;
224
+ HeaderContentStyle . padding = new RectOffset ( 15 , 15 , 10 , 10 ) ;
225
+
226
+ TabBoxStyle = new GUIStyle ( GUIStyle . none ) ;
227
+ TabBoxStyle . normal . textColor = Color . white ;
228
+ TabBoxStyle . alignment = TextAnchor . MiddleCenter ;
229
+ TabBoxStyle . margin = new RectOffset ( 15 , 15 , 0 , 0 ) ;
230
+ TabBoxStyle . padding = new RectOffset ( 20 , 20 , 0 , 0 ) ;
231
+
232
+ ButtonStyle = new GUIStyle ( GUIStyle . none )
233
+ {
234
+ fontSize = 12 ,
235
+ alignment = TextAnchor . MiddleCenter ,
236
+ normal = { textColor = Color . white }
237
+ } ;
238
+
239
+ TitleTextStyle = new GUIStyle ( EditorStyles . boldLabel )
240
+ {
241
+ fontSize = 14 ,
242
+ alignment = TextAnchor . MiddleCenter ,
243
+ normal = { textColor = Color . white }
244
+ } ;
245
+
246
+ HeaderTextStyle = new GUIStyle ( )
247
+ {
248
+ fontSize = 12 ,
249
+ normal = { textColor = Color . white }
250
+ } ;
179
251
}
180
252
}
181
253
182
254
public readonly struct PlateauToolkitImageButtonGUI
183
255
{
256
+ static Texture2D s_WhiteTexture ;
257
+ static Texture2D WhiteTexture
258
+ {
259
+ get
260
+ {
261
+ if ( s_WhiteTexture == null )
262
+ {
263
+ Color [ ] pixels = { Color . white } ;
264
+ var texture = new Texture2D ( 1 , 1 ) ;
265
+ texture . SetPixels ( pixels ) ;
266
+ texture . Apply ( ) ;
267
+
268
+ s_WhiteTexture = texture ;
269
+ }
270
+ return s_WhiteTexture ;
271
+ }
272
+ }
273
+
184
274
readonly float m_Width ;
185
275
readonly float m_Height ;
276
+ readonly Color m_Color ;
277
+ readonly bool m_IsPositionCenter ;
186
278
187
- public PlateauToolkitImageButtonGUI ( float width , float height )
279
+ public PlateauToolkitImageButtonGUI ( float width , float height , Color color , bool isPositionCenter = true )
188
280
{
189
281
m_Width = width ;
190
282
m_Height = height ;
283
+ m_Color = color ;
284
+ m_IsPositionCenter = isPositionCenter ;
191
285
}
192
286
193
- public bool Button ( string iconTexturePath , Color ? buttonColor = null )
287
+ public bool TabButton (
288
+ string iconTexturePath ,
289
+ Rect rect ,
290
+ bool isActive )
194
291
{
195
- Color defaultColor = GUI . backgroundColor ;
196
- using ( PlateauToolkitEditorGUILayout . BackgroundColorScope ( buttonColor . GetValueOrDefault ( defaultColor ) ) )
292
+ if ( isActive )
197
293
{
294
+ GUI . DrawTexture ( rect , WhiteTexture , ScaleMode . StretchToFill , true , 0 , m_Color , 0 , 4 ) ;
295
+ }
296
+
297
+ var buttonStyle = new GUIStyle ( GUIStyle . none ) ;
298
+ bool button = GUI . Button (
299
+ rect ,
300
+ ( Texture2D ) AssetDatabase . LoadAssetAtPath ( iconTexturePath , typeof ( Texture2D ) ) ,
301
+ buttonStyle ) ;
302
+
303
+ return button ;
304
+ }
305
+
306
+ public bool Button ( string label )
307
+ {
308
+ float scopeWidth = m_IsPositionCenter ? 0 : m_Width ;
309
+ using ( var scope = new EditorGUILayout . HorizontalScope ( GUILayout . Height ( m_Height ) , GUILayout . Width ( scopeWidth ) ) )
310
+ {
311
+ GUILayout . FlexibleSpace ( ) ;
312
+
313
+ float centerY = ( scope . rect . height - m_Height ) / 2 ;
314
+ float centerX = ( scope . rect . width - m_Width ) / 2 ;
315
+ var buttonRect = new Rect ( scope . rect . x + centerX , scope . rect . y + centerY , m_Width , m_Height ) ;
316
+
317
+ GUI . DrawTexture ( buttonRect , WhiteTexture , ScaleMode . StretchToFill , true , 0 , m_Color , 0 , 5 ) ;
318
+
198
319
bool button = GUILayout . Button (
199
- ( Texture2D ) AssetDatabase . LoadAssetAtPath ( iconTexturePath , typeof ( Texture2D ) ) ,
200
- GUILayout . Width ( m_Width ) ,
201
- GUILayout . Height ( m_Height ) ) ;
320
+ label ,
321
+ PlateauToolkitGUIStyles . ButtonStyle ,
322
+ GUILayout . Height ( m_Height ) ,
323
+ GUILayout . Width ( m_Width ) ) ;
202
324
325
+ GUILayout . FlexibleSpace ( ) ;
203
326
return button ;
204
327
}
205
328
}
206
329
207
- public bool Button ( Texture2D texture2D , Color ? buttonColor = null )
330
+ public bool Button ( Texture2D texture2D , RectOffset padding )
208
331
{
209
- Color defaultColor = GUI . backgroundColor ;
210
- using ( PlateauToolkitEditorGUILayout . BackgroundColorScope ( buttonColor . GetValueOrDefault ( defaultColor ) ) )
332
+ using ( var scope = new EditorGUILayout . HorizontalScope ( GUILayout . Height ( m_Height ) ) )
211
333
{
334
+ GUILayout . FlexibleSpace ( ) ;
335
+
336
+ float centerY = ( scope . rect . height - m_Height ) / 2 ;
337
+ float centerX = ( scope . rect . width - m_Width ) / 2 ;
338
+ var buttonRect = new Rect ( scope . rect . x + centerX , scope . rect . y + centerY , m_Width , m_Height ) ;
339
+
340
+ GUI . DrawTexture ( buttonRect , WhiteTexture , ScaleMode . StretchToFill , true , 0 , m_Color , 0 , 5 ) ;
341
+
342
+ var style = PlateauToolkitGUIStyles . ButtonStyle ;
343
+ style . padding = padding ;
344
+
212
345
bool button = GUILayout . Button (
213
346
texture2D ,
214
- GUILayout . Width ( m_Width ) ,
215
- GUILayout . Height ( m_Height ) ) ;
347
+ style ,
348
+ GUILayout . Height ( m_Height ) ,
349
+ GUILayout . Width ( m_Width ) ) ;
216
350
351
+ GUILayout . FlexibleSpace ( ) ;
217
352
return button ;
218
353
}
219
354
}
0 commit comments