@@ -79,6 +79,8 @@ public class UIEffect2Editor : Editor
79
79
private SerializedProperty _gradationMode ;
80
80
private SerializedProperty _gradationColor1 ;
81
81
private SerializedProperty _gradationColor2 ;
82
+ private SerializedProperty _gradationColor3 ;
83
+ private SerializedProperty _gradationColor4 ;
82
84
private SerializedProperty _gradationGradient ;
83
85
private SerializedProperty _gradationOffset ;
84
86
private SerializedProperty _gradationScale ;
@@ -163,6 +165,8 @@ private void OnEnable()
163
165
_gradationMode = serializedObject . FindProperty ( "m_GradationMode" ) ;
164
166
_gradationColor1 = serializedObject . FindProperty ( "m_GradationColor1" ) ;
165
167
_gradationColor2 = serializedObject . FindProperty ( "m_GradationColor2" ) ;
168
+ _gradationColor3 = serializedObject . FindProperty ( "m_GradationColor3" ) ;
169
+ _gradationColor4 = serializedObject . FindProperty ( "m_GradationColor4" ) ;
166
170
_gradationGradient = serializedObject . FindProperty ( "m_GradationGradient" ) ;
167
171
_gradationOffset = serializedObject . FindProperty ( "m_GradationOffset" ) ;
168
172
_gradationScale = serializedObject . FindProperty ( "m_GradationScale" ) ;
@@ -340,22 +344,19 @@ public void DrawProperties()
340
344
case GradationMode . AngleGradient :
341
345
DrawGradientField ( _gradationGradient ) ;
342
346
break ;
347
+ case GradationMode . Diagonal :
348
+ DrawColorPickerField ( "Top" , _gradationColor1 , _gradationColor2 ) ;
349
+ DrawColorPickerField ( "Bottom" , _gradationColor3 , _gradationColor4 ) ;
350
+ break ;
343
351
default :
344
- DrawColorPickerField ( _gradationColor1 ) ;
352
+ DrawColorPickerField ( EditorGUILayout . GetControlRect ( ) , _gradationColor1 , true ) ;
345
353
var r = EditorGUILayout . GetControlRect ( ) ;
346
354
r . width -= 24 ;
347
- r . height = EditorGUIUtility . singleLineHeight ;
348
- DrawColorPickerField ( r , _gradationColor2 ) ;
355
+ DrawColorPickerField ( r , _gradationColor2 , true ) ;
349
356
350
357
r . x += r . width + 4 ;
351
358
r . width = 20 ;
352
- // Swap colors
353
- if ( GUI . Button ( r , EditorGUIUtility . IconContent ( "preaudioloopoff" ) , "iconbutton" ) )
354
- {
355
- ( _gradationColor1 . colorValue , _gradationColor2 . colorValue )
356
- = ( _gradationColor2 . colorValue , _gradationColor1 . colorValue ) ;
357
- }
358
-
359
+ SwapColorsButton ( r , _gradationColor1 , _gradationColor2 ) ;
359
360
break ;
360
361
}
361
362
@@ -405,17 +406,35 @@ public void DrawProperties()
405
406
}
406
407
}
407
408
408
- private static void DrawColorPickerField ( SerializedProperty color , bool showAlpha = true )
409
+ private static void DrawColorPickerField ( string label , SerializedProperty color1 , SerializedProperty color2 )
409
410
{
411
+ var labelWidth = EditorGUIUtility . labelWidth ;
410
412
var r = EditorGUILayout . GetControlRect ( ) ;
411
- r . height = EditorGUIUtility . singleLineHeight ;
412
- DrawColorPickerField ( r , color , showAlpha ) ;
413
+ r . width -= 24 ;
414
+ EditorGUI . PrefixLabel ( new Rect ( r . x , r . y , labelWidth , r . height ) , EditorGUIUtility . TrTempContent ( label ) ) ;
415
+
416
+ var indentLevel = EditorGUI . indentLevel ;
417
+ EditorGUI . indentLevel = 0 ;
418
+ var rPos = new Rect ( r . x + labelWidth , r . y , ( r . width - labelWidth ) / 2 , r . height ) ;
419
+ DrawColorPickerField ( rPos , GUIContent . none , color1 , true ) ;
420
+
421
+ rPos . x += rPos . width ;
422
+ DrawColorPickerField ( rPos , GUIContent . none , color2 , true ) ;
423
+
424
+ // Swap colors button
425
+ SwapColorsButton ( new Rect ( r . x + r . width + 4 , r . y , 20 , 20 ) , color1 , color2 ) ;
426
+ EditorGUI . indentLevel = indentLevel ;
413
427
}
414
428
415
- private static void DrawColorPickerField ( Rect rect , SerializedProperty color , bool showAlpha = true )
429
+ private static void DrawColorPickerField ( Rect rect , SerializedProperty color , bool showAlpha )
416
430
{
417
431
var label = EditorGUIUtility . TrTempContent ( color . displayName ) ;
418
432
label . tooltip = color . tooltip ;
433
+ DrawColorPickerField ( rect , label , color , showAlpha ) ;
434
+ }
435
+
436
+ private static void DrawColorPickerField ( Rect rect , GUIContent label , SerializedProperty color , bool showAlpha )
437
+ {
419
438
var hdr = UIEffectProjectSettings . useHdrColorPicker ;
420
439
EditorGUI . showMixedValue = color . hasMultipleDifferentValues ;
421
440
@@ -430,8 +449,6 @@ private static void DrawColorPickerField(Rect rect, SerializedProperty color, bo
430
449
private static void DrawGradientField ( SerializedProperty gradient )
431
450
{
432
451
var r = EditorGUILayout . GetControlRect ( ) ;
433
- r . height = EditorGUIUtility . singleLineHeight ;
434
-
435
452
var label = EditorGUIUtility . TrTempContent ( gradient . displayName ) ;
436
453
label . tooltip = gradient . tooltip ;
437
454
var hdr = UIEffectProjectSettings . useHdrColorPicker ;
@@ -480,7 +497,7 @@ private static void DrawColor(SerializedProperty color, ColorFilter filter, Colo
480
497
color . colorValue = Color . white ;
481
498
}
482
499
483
- DrawColorPickerField ( color , showAlpha ) ;
500
+ DrawColorPickerField ( EditorGUILayout . GetControlRect ( ) , color , showAlpha ) ;
484
501
}
485
502
}
486
503
@@ -502,6 +519,14 @@ private static void DrawColor(SerializedProperty filter, SerializedProperty colo
502
519
EditorGUI . indentLevel -- ;
503
520
}
504
521
522
+ private static void SwapColorsButton ( Rect rect , SerializedProperty color1 , SerializedProperty color2 )
523
+ {
524
+ if ( GUI . Button ( rect , EditorGUIUtility . IconContent ( "preaudioloopoff" ) , "iconbutton" ) )
525
+ {
526
+ ( color1 . colorValue , color2 . colorValue ) = ( color2 . colorValue , color1 . colorValue ) ;
527
+ }
528
+ }
529
+
505
530
private static bool DrawHeaderPopup ( SerializedProperty sp )
506
531
{
507
532
var r = EditorGUILayout . GetControlRect ( ) ;
0 commit comments