Skip to content

Commit

Permalink
Add standard vertical spacing to some drawers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nitz committed Nov 16, 2021
1 parent 178959b commit f72b2d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class InfoBoxDecoratorDrawer : DecoratorDrawer
{
public override float GetHeight()
{
return GetHelpBoxHeight();
return GetHelpBoxHeight() + EditorGUIUtility.standardVerticalSpacing;
}

public override void OnGUI(Rect rect)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,19 @@ 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);
Rect helpBoxRect = new Rect(
rect.x + indentLength,
rect.y,
rect.width - indentLength,
GetHelpBoxHeight());
GetHelpBoxHeight() - GetHelpBoxPadding());

NaughtyEditorGUI.HelpBox(helpBoxRect, message, MessageType.Warning, context: property.serializedObject.targetObject);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};

Expand Down

0 comments on commit f72b2d7

Please sign in to comment.