Search Unity

  1. Unity 2019.1 beta is now available.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. On February 28th the Feedback website will shut down and be redirected to the Unity forums. See the full post for more information.
    Dismiss Notice
  5. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  6. Unity 2018.3 is now released.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

EditorGUILayout.xxxField, label covered by the field

Discussion in 'Extensions & OnGUI' started by libra34567, Jun 20, 2018.

  1. libra34567


    Apr 5, 2014
    So on the image below, I copied the lighting window's parameter to my own editor, you can see that for Indirect Sampling my label for that field is covered by the field. How do I avoid that?


    And also, if i use BeginHorizontal, EndHorizontal, and put a few button, label etc in it, how do i orgnize their position/size with in it? For example i can leave more space for my label but less space for my toggle.

    Thank you in advance.
  2. Hosnkobf


    Aug 23, 2016
    first question:
    I am not sure, but I think you can change the
    make the label wider. I would recommend to store the original value in a temporary variable, then set it at the beginning of your gui code to another value and restore the original label width at the end of the gui code (to not mess with other editors).

    second question:
    you can pass several
    objects to all of the ui-element-functions. You can use some handy static classes inside
    to create them.
    There is:
    • GUILayout.Width(width)
      for a fixed width
    • GUILayout.MinWidth(width)
      to prevent the element to get too small
    • GUILayout.MaxWidth(width)
      to prevent the element to get too big
    • GUILayout.ExpandWidth()
      to fill up empty space with the element
    the same is available for height.