Get height of a group of GUILayout controls

Is there a way to get the height of a collection of Editor/GUILayout controls? I know that you can use GUILayoutUtility.GetLastRect to get the height of the last control, but what about fetching the height of the following:

void DoLayout() {
    EditorGUILayout.IntField("myInt", 32);

where DoLayout contains arbitrary Editor\GUILayout commands?

For example, is there some control that I could wrap DoLayout in? ie,

float GetGroupHeight(Action group) {
    GUILayout.BeginZone(); // made up function
    GUILayout.EndZone(); // made up function
    return GUILayoutUtility.GetLastHeight().height;

where GetGroupHeight works recursively?


Maybe it’s too late to answer the question, but I looked for it too and found the way to do it. So I’ll post an answer for myself to find it later or for someone else who is looking for it too. The idea is to call GUILayoutUtility.GetLastRect() after some layout group, so it will capture the rect of the group. You should call it when EventType.Repaint occurred and save to class variable. Here is an example:

private Rect _buttonsRect;

public override void OnInspectorGUI ()
    if( GUILayout.Button( "Log Buttons Rect" ) )
        Debug.Log( "Buttons rect: " + _buttonsRect );

    for( int i = 0; i < 25; ++i )
        GUILayout.Button( "Button " + i );

    if( Event.current.type == EventType.Repaint )
        _buttonsRect = GUILayoutUtility.GetLastRect();