EditorGUILayout.BeginVertical indent level

Hi all,

I created an editor with some vertical groups in it and i want to give indent to them. Everything works fine except the style of the group. If i apply a style to that vertical group after giving an indent like:


the label moves right as expected but the box is drawn as wide as the inspector window no matter what. I tried adding gui layout option width but it didn’t work. Any ideas?

The static “indentLevel” is only used by certain controls, mainly for their LabelField. It has no influence on how styles are drawn. As you might know the layout controls in almost all cases just wrap the normal EditorGUI controls but use EditorLayoutUtility.GetRect to aquire a layouted rect. The control itself will add the indent to it’s rect. This is not the case for layout groups.

Note that the indent level is meant for the inspector only. You can “manually” indent a certain layout group by nesting it in a horizontal group with a “GUILayout.Space” as first element to specify the indent

  GUILayout.Space(indent amount);
    // some content

This will indent the whole box of the vertical group. Though if you want to mix your controls in the inspector with other things that have normal indented labels they probably won’t line up. So it depends on what you want to do. By default layout groups do not have any concept of indention.