Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    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. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  4. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

EditorGUILayout.xxxField, label covered by the field

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

  1. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    26
    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?

    qso.PNG

    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

    Hosnkobf

    Joined:
    Aug 23, 2016
    Posts:
    392
    first question:
    I am not sure, but I think you can change the
    EditorGUIUtility.labelWidth
    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
    GUILayoutOption
    objects to all of the ui-element-functions. You can use some handy static classes inside
    GUILayout
    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.