Custom Editor Inspector side-distance

Ok, so I am just developing my first real game in unity and to make my room-preset editor easier to understand I decided to replace two ints (width & length) with two custom sliders.
I created a custom Vector2Int class and a drawer. Worked fine. After a bit of struggeling I even maaged to stop the slider from lagging.

Then I resized my window. Big mistake. It looks like my slider is not always lined up with the unity fields.
Can someone provide my with the correct values to fix this?

Problem

Code:

using UnityEngine;
using UnityEditor;

[CustomPropertyDrawer(typeof(Vector2Int))]
public class Vector2IntDrawer : PropertyDrawer
{
        float fx =3;
    int ix = 3;

    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {

        SerializedProperty x = property.FindPropertyRelative("x");
        SerializedProperty z = property.FindPropertyRelative("z");


        EditorGUI.LabelField(new Rect(position.xMin, position.yMin, position.width, position.height), label);

        // Check if modified, to avoid overwriting the property constantly
    EditorGUI.BeginChangeCheck();
        int newX = EditorGUI.IntField(new Rect(position.x + position.width * 0.4f, position.y, position.width, position.height), "X", x.intValue);
        if (newX < 0) newX = 0;
        if (EditorGUI.EndChangeCheck())
        {
            x.intValue = newX;
        }


    }

    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        return base.GetPropertyHeight(property, label);
    }
}

Theres this function MultiFloatField

which might help
Or just use the defualt vector2field, and rounds the values to ints in changeCheck

as for why your code is doing that, you have told it to start the field at 40% the width of position
presumably the default v2field doesn;t do this

By using GUILayout.Width you can edit the module’s width in order to make it fit as you want.

Yeah, the 40% are just one of my closest attempts. I have tried different numbers for hours now. I was hoping that maybe someone with access to the unity source Code could tell me the exact values. :smile: