Skip to content

BepInEx.OptimizeIMGUI Nested ExpandHeight in Vertical Group #6

@JustAGuest4168

Description

@JustAGuest4168

When nesting Vertical and Horizontal Groups, I discovered an issue with a Button with ExpandHeight(true) inside a Horizontal Group nested inside another Vertical Group with ExpandHeight(false) causing the Vertical Groups ExpandHeight(false) to be negated. Screenshots of with and without BepInEx.OptimizeIMGUI and condensed sample code below.

Without BepInEx.OptimizeIMGUI (Correct):
image

With BepInEx.OptimizeIMGUI (Incorrect):
image

Condensed Sample code:

public class NewBehaviourScript : MonoBehaviour
{
    private Rect uiWindow2 = new Rect(UnityEngine.Screen.width / 2 + 20, 20, 120, 400);
    private void OnGUI()
    {
        uiWindow2 = GUILayout.Window(34566, uiWindow2, DisplayUIWindowX, "TEST");
    }
    private void DisplayUIWindowX(int windowId)
    {
        GUILayout.BeginVertical(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        {
            //Header
            GUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));
            {
                //Toolbar
                {
                    GUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
                    {
                        //Header
                        GUILayout.Label("TEST", GUILayout.ExpandWidth(true));

                        //Options
                        if (GUILayout.Button("O", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
                        {
                        }
                    }
                    GUILayout.EndHorizontal();

                    //Options
                }
            }
            GUILayout.EndVertical();

            //Content
            GUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
            {
                //Abstract
                //this.DisplayUIWindowBase();
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndVertical();

            //Info
            GUILayout.BeginVertical("box", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(false));
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Info: " + "", GUILayout.ExpandWidth(true));
                    if (GUILayout.Button("Clear", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
                    {
                        //info = "";
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }
        GUILayout.EndVertical();

        GUI.DragWindow();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions