EditorGUI.PrefixLabel gets truncated

Hi!

I’m currently implementing a custom property drawer for an attribute.

To create a label previewing an icon, I’ve added this to my property drawer:

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
  EditorGUI.BeginProperty(position, label, property);

  var controlId = GUIUtility.GetControlID(FocusType.Passive, position);
  position = EditorGUI.PrefixLabel(position, controlId, new GUIContent(previewIcon),
    new GUIStyle(EditorStyles.label) { fontSize = 46 });

  EditorGUI.EndProperty();
}

public override float GetPropertyHeight(SerializedProperty property, GUIContent label) => 46;

As you can see, I return 46 as height for the label and also 46 for the font size. However, the text is truncated even there is more space available:

8159654--1060730--upload_2022-5-26_21-19-37.png

I’d expect that at least it should not be truncated at the bottom.

What else do I need to do, that the label uses more space to fully show the text?

Thanks!

Ok, I found it.

The rect itself had the correct position. However, for the GUIStyle you also need to set the height.

So instead of doing this:

 new GUIStyle(EditorStyles.label) { fontSize = 46 }

It needs to be this here:

 new GUIStyle(EditorStyles.label) { fontSize = 46, fixedHeight = 46 }