Unity Property Drawer - Making more space

I have a problem creating my custom GUI layout. I don’t know how to make more space for my labels so they don’t get on each other like here

39661-as2.png

I saw this post but it didn’t help me. Property Drawer and Children - Unity Answers

My code for Property Drawer is here:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomPropertyDrawer(typeof(Level))]
public class LevelType : PropertyDrawer {

public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 
{
	EditorGUI.BeginProperty(position, label, property);
	EditorGUIUtility.LookLikeControls();
	int indent = EditorGUI.indentLevel;
	EditorGUI.indentLevel = 0;
	
	Rect w1 = new Rect(position.x, position.y, 50, position.height);
	Rect w2 = new Rect(position.x+60, position.y, 25, position.height);
	EditorGUI.LabelField(w1, "Health", GUIStyle.none);
	EditorGUI.PropertyField(w2, property.FindPropertyRelative ("Balls"), GUIContent.none);

	Rect w3 = new Rect(position.x, position.y+30, 50, position.height);
	Rect w4 = new Rect(position.x+60, position.y+30, 25, position.height);
	EditorGUI.LabelField(w3, "Mana", GUIStyle.none);
	EditorGUI.PropertyField(w4, property.FindPropertyRelative ("Balls"), GUIContent.none);

	EditorGUI.EndProperty();
	
	
}

}

You need to overwrite the GetPropertyHeight function and return the height you want it to use.

Some code to help with this. Kinda a hack way of doing it but it works.

//need to set field amount manually if you add more fields
    private int fieldAmount = 4;
    private float fieldSize = 16;
    private float padding = 2;

    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        //set the height of the drawer by the field size and padding
        return (fieldSize * fieldAmount)+(padding * fieldAmount);
    }

    // Draw the property inside the given rect
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {

        //divide all field heights by the field amount..then minus the padding
        position.height /= fieldAmount; position.height -= padding;

        // Using BeginProperty / EndProperty on the parent property means that
        // prefab override logic works on the entire property.
        EditorGUI.BeginProperty(position, label, property);
        
        //first field of the drawer
        EditorGUI.PropertyField(position,data);

        position.y += fieldSize + padding; //offset position.y by field size
        savedData.id = EditorGUI.IntField(position, savedData.id);

        position.y += fieldSize + padding;
        savedData.id = EditorGUI.IntField(position, savedData.id);

        position.y += fieldSize + padding;
        savedData.id = EditorGUI.IntField(position, savedData.id);


        EditorGUI.EndProperty();
    }