From e229506bb8c90ee2c0c5ae2e958cbb06508973e4 Mon Sep 17 00:00:00 2001 From: Chris Dailey Date: Tue, 16 Nov 2021 10:12:08 -0500 Subject: [PATCH] Add standard vertical spacing to some drawers. A few drawers needed a little breathing room from the controls that followed them, in particular InfoBox and the help box drawn from `DrawDefaultPropertyAndHelpBox`. Added EditorGUIUtility.standardVerticalSpacing to the heights for those instances. As well, used EditorGUIUtility.standardVerticalSpacing for the height of controls inside a reorderable list, instead of the hardcoded value 4. --- .../Editor/DecoratorDrawers/InfoBoxDecoratorDrawer.cs | 2 +- .../Scripts/Editor/PropertyDrawers/PropertyDrawerBase.cs | 7 ++++++- .../ReorderableListPropertyDrawer.cs | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Assets/NaughtyAttributes/Scripts/Editor/DecoratorDrawers/InfoBoxDecoratorDrawer.cs b/Assets/NaughtyAttributes/Scripts/Editor/DecoratorDrawers/InfoBoxDecoratorDrawer.cs index 18a979c2..08841509 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/DecoratorDrawers/InfoBoxDecoratorDrawer.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/DecoratorDrawers/InfoBoxDecoratorDrawer.cs @@ -8,7 +8,7 @@ public class InfoBoxDecoratorDrawer : DecoratorDrawer { public override float GetHeight() { - return GetHelpBoxHeight(); + return GetHelpBoxHeight() + EditorGUIUtility.standardVerticalSpacing; } public override void OnGUI(Rect rect) diff --git a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/PropertyDrawerBase.cs b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/PropertyDrawerBase.cs index 883d1ffa..88873d88 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/PropertyDrawerBase.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers/PropertyDrawerBase.cs @@ -71,6 +71,11 @@ public virtual float GetHelpBoxHeight() return EditorGUIUtility.singleLineHeight * 2.0f; } + protected virtual float GetHelpBoxPadding() + { + return EditorGUIUtility.standardVerticalSpacing; + } + public void DrawDefaultPropertyAndHelpBox(Rect rect, SerializedProperty property, string message, MessageType messageType) { float indentLength = NaughtyEditorGUI.GetIndentLength(rect); @@ -78,7 +83,7 @@ public void DrawDefaultPropertyAndHelpBox(Rect rect, SerializedProperty property rect.x + indentLength, rect.y, rect.width - indentLength, - GetHelpBoxHeight()); + GetHelpBoxHeight() - GetHelpBoxPadding()); NaughtyEditorGUI.HelpBox(helpBoxRect, message, MessageType.Warning, context: property.serializedObject.targetObject); diff --git a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers_SpecialCase/ReorderableListPropertyDrawer.cs b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers_SpecialCase/ReorderableListPropertyDrawer.cs index 3790442b..853f37f6 100644 --- a/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers_SpecialCase/ReorderableListPropertyDrawer.cs +++ b/Assets/NaughtyAttributes/Scripts/Editor/PropertyDrawers_SpecialCase/ReorderableListPropertyDrawer.cs @@ -75,7 +75,7 @@ protected override void OnGUI_Internal(Rect rect, SerializedProperty property, G elementHeightCallback = (int index) => { - return EditorGUI.GetPropertyHeight(property.GetArrayElementAtIndex(index)) + 4.0f; + return EditorGUI.GetPropertyHeight(property.GetArrayElementAtIndex(index)) + EditorGUIUtility.standardVerticalSpacing; } };