EditorGUILayout.Vector*Field don't look like inspector

This snippet in EditorWindow.OnGUI:

    EditorGUILayout.BeginVertical();
    vec = EditorGUILayout.Vector2Field("Vec2", vec);
    EditorGUILayout.EndVertical();

renders a Vector2 field with the X and Y fields below the “Vec2” label. The Vector2 fields resize to the size of the EditorWindow. It looks like this:

alt text

However, in the built-in inspector, the Vector2 field changes depending on the width of the inspector window. When there is plenty of room, the fields are to the right of the label, but when there isn’t much room the fields move down below the label. This also happens with Vector3. Vector4 in the inspector has a foldout but EditorGUILayout.Vector4Field doesn’t.

Does anyone know why this is so? I want to make my custom property window look as similar as possible to the inspector but I’m finding that I’m having to implement things myself that I thought would have been provided like the vector fields. I’m also having to do a few little hacks to get things to line up the same as the inspector window.

You have to enable EditorGUIUtility.wideMode if you want GUI controls for structs to look like those in the built-in inspector.