Search Unity

Bug Inconsistent window size when using GUILayout.Window

Discussion in 'Immediate Mode GUI (IMGUI)' started by Aka_ToolBuddy, Oct 4, 2020.

  1. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    547
    Hi,

    GUILayout.Window has changed behavior between old editor UI (pre 2019.3) and the new one. Here is a simple code that shows the problem:
    for (int j = 0; j < 5; j++)
    GUILayout.Window(j, new Rect(j * 50, 5, 50, 50), null, "");

    And here are the results:

    Old UI
    upload_2020-10-4_21-14-3.png

    New UI
    upload_2020-10-4_21-14-18.png

    You can see that the rectangles are smaller in the new UI. I want to get the same size of the rectangle, whatever the size of the shadow is.

    Any help is appreciated.
    Thanks
     
  2. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    547
    I noticed this issue happens only when the method is called in an Editor window

    Old UI
    upload_2020-10-6_0-15-48.png

    New UI
    upload_2020-10-6_0-17-3.png
     
  3. Aka_ToolBuddy

    Aka_ToolBuddy

    Joined:
    Feb 25, 2014
    Posts:
    547
    For those interested in the explanation, I found that the default style for the windows (GUI.skin.window) is different between old and new UI. And even when using the same values, I got different results.