Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Only one of two Lists show in EditorGUILayout Horizontal

Discussion in 'Immediate Mode GUI (IMGUI)' started by shermenz, Dec 24, 2020.

  1. shermenz

    shermenz

    Joined:
    Jan 19, 2015
    Posts:
    3
    Hello everyone, I've been reading everything I can about the subject but can't find the solution.

    I'm building an a tool which inherent from EditorWindow .
    One of things I want to do is show two List<Sprite> next to each other.

    And for some reason the editor show the one on the left, but not the one on the right.
    The editor does seem to account for the list on the right, when I open the dropdown The layout seem to move in accordance with the amount of elements there is in the list.

    I've added pictures where you can see what happens if I switch between the two lists in the code.
    Thank you very much!

    Code (CSharp):
    1. public class EventsDuplicatorGUI : EditorWindow
    2. {
    3.    private SerializedObject eventType;
    4.    private SerializedProperty templateFiles;
    5.    private SerializedProperty newSprites;
    6.  
    7.  
    8. private void OnEnable()
    9. {
    10.     eventType = new SerializedObject(m_eventType);
    11.  
    12.     newSprites = eventType.FindProperty("NewSpritesList");
    13.     templateFiles = eventType.FindProperty("TemplateSpritesList");
    14. }
    15.  
    16.  
    17. private void OnGUI()
    18. {
    19.    
    20.    EditorGUILayout.BeginHorizontal();
    21.  
    22.    EditorGUILayout.PropertyField(newSprites, true);
    23.    EditorGUILayout.PropertyField(templateFiles, true);
    24.  
    25.    EditorGUILayout.EndHorizontal();
    26.  
    27. }
    28. }
     

    Attached Files:

  2. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Did a lazy test with a custom inspector (not quite an editor window but layout should work the same).

    Code (csharp):
    1.  
    2. using(new EditorGUILayout.HorizontalScope())
    3. {
    4.      EditorGUILayout.PropertyField(arrayOne,true);
    5.      EditorGUILayout.PropertyField(arrayTwo,true);
    6. }
    7.  
    This worked fine for me.