@@ -13,6 +13,43 @@ namespace UnityEditor.ProBuilder.UI
13
13
/// </summary>
14
14
static class EditorGUIUtility
15
15
{
16
+ static class Styles
17
+ {
18
+ static bool s_Initialized ;
19
+
20
+ public static GUIStyle command = "command" ;
21
+ public static GUIContent [ ] selectModeIcons ;
22
+
23
+ public static void Init ( )
24
+ {
25
+ if ( s_Initialized )
26
+ return ;
27
+
28
+ s_Initialized = true ;
29
+
30
+ var object_Graphic_off = IconUtility . GetIcon ( "Modes/Mode_Object" ) ;
31
+ var face_Graphic_off = IconUtility . GetIcon ( "Modes/Mode_Face" ) ;
32
+ var vertex_Graphic_off = IconUtility . GetIcon ( "Modes/Mode_Vertex" ) ;
33
+ var edge_Graphic_off = IconUtility . GetIcon ( "Modes/Mode_Edge" ) ;
34
+
35
+ selectModeIcons = new GUIContent [ ]
36
+ {
37
+ object_Graphic_off != null
38
+ ? new GUIContent ( object_Graphic_off , "Object Selection" )
39
+ : new GUIContent ( "OBJ" , "Object Selection" ) ,
40
+ vertex_Graphic_off != null
41
+ ? new GUIContent ( vertex_Graphic_off , "Vertex Selection" )
42
+ : new GUIContent ( "VRT" , "Vertex Selection" ) ,
43
+ edge_Graphic_off != null
44
+ ? new GUIContent ( edge_Graphic_off , "Edge Selection" )
45
+ : new GUIContent ( "EDG" , "Edge Selection" ) ,
46
+ face_Graphic_off != null
47
+ ? new GUIContent ( face_Graphic_off , "Face Selection" )
48
+ : new GUIContent ( "FCE" , "Face Selection" ) ,
49
+ } ;
50
+ }
51
+ }
52
+
16
53
static readonly Color TOOL_SETTINGS_COLOR = UnityEditor . EditorGUIUtility . isProSkin
17
54
? Color . green
18
55
: new Color ( .2f , .2f , .2f , .2f ) ;
@@ -379,5 +416,54 @@ public static void SceneLabel(string text, Vector2 position)
379
416
380
417
GUI . Label ( sceneLabelRect , gc , sceneBoldLabel ) ;
381
418
}
419
+
420
+ public static SelectMode DoElementModeToolbar ( Rect rect , SelectMode mode )
421
+ {
422
+ Styles . Init ( ) ;
423
+
424
+ EditorGUI . BeginChangeCheck ( ) ;
425
+
426
+ var textureMode = mode . ContainsFlag ( SelectMode . TextureVertex | SelectMode . TextureEdge | SelectMode . TextureFace ) ;
427
+
428
+ int currentSelectionMode = - 1 ;
429
+
430
+ switch ( mode )
431
+ {
432
+ case SelectMode . Object :
433
+ currentSelectionMode = 0 ;
434
+ break ;
435
+ case SelectMode . Vertex :
436
+ case SelectMode . TextureVertex :
437
+ currentSelectionMode = 1 ;
438
+ break ;
439
+ case SelectMode . Edge :
440
+ case SelectMode . TextureEdge :
441
+ currentSelectionMode = 2 ;
442
+ break ;
443
+ case SelectMode . Face :
444
+ case SelectMode . TextureFace :
445
+ currentSelectionMode = 3 ;
446
+ break ;
447
+ default :
448
+ currentSelectionMode = - 1 ;
449
+ break ;
450
+ }
451
+
452
+ currentSelectionMode = GUI . Toolbar ( rect , currentSelectionMode , Styles . selectModeIcons , Styles . command ) ;
453
+
454
+ if ( EditorGUI . EndChangeCheck ( ) )
455
+ {
456
+ if ( currentSelectionMode == 0 )
457
+ mode = SelectMode . Object ;
458
+ else if ( currentSelectionMode == 1 )
459
+ mode = textureMode ? SelectMode . TextureVertex : SelectMode . Vertex ;
460
+ else if ( currentSelectionMode == 2 )
461
+ mode = textureMode ? SelectMode . TextureEdge : SelectMode . Edge ;
462
+ else if ( currentSelectionMode == 3 )
463
+ mode = textureMode ? SelectMode . TextureFace : SelectMode . Face ;
464
+ }
465
+
466
+ return mode ;
467
+ }
382
468
}
383
469
}
0 commit comments