Search Unity

EditorGUILayout.xxxField, label covered by the field

Discussion in 'Immediate Mode GUI (IMGUI)' started by libra34567, Jun 20, 2018.

  1. libra34567

    libra34567

    Joined:
    Apr 5, 2014
    Posts:
    62
    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:
    1,096
    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.