@@ -19,9 +19,11 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
19
19
string joinedNames = string . Join ( " | " , currentEnums ) ;
20
20
label . text += " [" + joinedNames + "]" ;
21
21
label . tooltip = joinedNames ;
22
+
23
+ float lineHeight = EditorGUIUtility . singleLineHeight ;
24
+ float space = EditorGUIUtility . standardVerticalSpacing ;
22
25
23
- float labelHeight = EditorGUI . GetPropertyHeight ( SerializedPropertyType . String , label ) ;
24
- var entryRect = new Rect ( position . x , position . y , position . width , labelHeight ) ;
26
+ var entryRect = new Rect ( position . x , position . y , position . width , lineHeight ) ;
25
27
property . isExpanded = EditorGUI . PropertyField ( entryRect , property , label ) ;
26
28
if ( ! property . isExpanded )
27
29
{
@@ -30,7 +32,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
30
32
31
33
EditorGUI . indentLevel ++ ;
32
34
// "Select All" | "Unselect All" buttons
33
- entryRect . y += entryRect . height ;
35
+ entryRect . y += space + entryRect . height ;
34
36
var buttonRect = new Rect ( entryRect . position , entryRect . size * new Vector2 ( 0.5f , 1f ) - BUTTON_PADDING ) ;
35
37
bool selectAll = GUI . Button ( buttonRect , "Select All" ) ;
36
38
buttonRect . x += entryRect . width * 0.5f + BUTTON_PADDING . x ;
@@ -41,8 +43,7 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
41
43
. Where ( entry =>
42
44
{
43
45
var content = new GUIContent ( entry . name ) ;
44
- entryRect . y += entryRect . height ;
45
- entryRect . height = EditorGUI . GetPropertyHeight ( SerializedPropertyType . Boolean , content ) ;
46
+ entryRect . y += space + entryRect . height ;
46
47
bool hasValue = ! unselectAll && ( selectAll || currentEnums . Contains ( entry . name ) ) ;
47
48
return EditorGUI . Toggle ( entryRect , content , hasValue ) ;
48
49
}
@@ -54,17 +55,16 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
54
55
55
56
public override float GetPropertyHeight ( SerializedProperty property , GUIContent label )
56
57
{
57
- float height = EditorGUI . GetPropertyHeight ( SerializedPropertyType . String , label ) ;
58
-
59
- if ( ! property . isExpanded )
58
+ float lineHeight = EditorGUIUtility . singleLineHeight ;
59
+ float space = EditorGUIUtility . standardVerticalSpacing ;
60
+
61
+ float height = lineHeight ;
62
+ if ( property . isExpanded )
60
63
{
61
- return height ;
64
+ height += space + lineHeight ; // "Select All" | "Unselect All" buttons
65
+ height += GetEnumType ( ) . GetEnumNames ( ) . Length * ( space + lineHeight ) ;
62
66
}
63
-
64
- return height
65
- + height // "Select All" | "Unselect All" buttons
66
- + GetEnumType ( ) . GetEnumNames ( )
67
- . Sum ( name => EditorGUI . GetPropertyHeight ( SerializedPropertyType . Boolean , new GUIContent ( name ) ) ) ;
67
+ return height ;
68
68
}
69
69
70
70
private Type GetEnumType ( )
0 commit comments