Search Unity

10 years of flexible EditorGUILayout, why is it so hard?

Discussion in 'UGUI & TextMesh Pro' started by bitinn, Jun 4, 2020.

  1. bitinn

    bitinn

    Joined:
    Aug 20, 2016
    Posts:
    961
    There is something I never quite understand about Unity UI's auto layout philosophy:

    - say I have a GUILayout.Window;
    - say I have a EditorGUILayout.BeginHorizontal / EndHorizontal group inside it;
    - say I have 2 GUILayout.Button inside the group.

    Why is it so damn hard to make buttons 50% width each?

    Why does it have to depend on either width of content, or a fixed width?

    Why can't I say, I have set the width of GUILayout.Window, don't ever expand it, instead, use it to auto layout the rest of children inside?

    (I know we are moving onto UI Element, but still, why is it like this?)

    (by 10 years I mostly mean people visiting this thread since 2011...)
     
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,052
    Yea... that is one of the many annoying things about ugui/GUILayout. It would be awesome to just percentages. The only way I was able actually solve this problem was to get the width of the parent and then do the math to set the width of the children. It works, but really is the long way around.