Search Unity

Question Make next item on reorderable list further down in the editor

Discussion in 'Editor & General Support' started by StrangeWays777, Mar 1, 2021.

  1. StrangeWays777

    StrangeWays777

    Joined:
    Jul 21, 2018
    Posts:
    31
    As you can see from the image I am trying to make variables on another line, I don't want all the variables on the same line otherwise the width will end up taking up the whole screen.

    https://ibb.co/JkThghP


    My problem is the next item on the list overlaps the variables of the second line of variables for the first item.

    I've been searching for hours for a solution and I'm new to Editor scripting, I just can't seem to find the answer.

    I tried using EditorGUILayout.BeginVertical("window"); + EditorGUILayout..Space(20f); + EditorGUILayout.EndVertical();

    Which was the closest I could get to my desired result but then the items were outside of the reorderable list

    https://ibb.co/kh1FGCv


    What am I doing wrong?

    Here's the code:

    Code (CSharp):
    1. list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
    2.         {
    3.             var element = list.serializedProperty.GetArrayElementAtIndex(index);
    4.             rect.y += 2;
    5.  
    6.             rect = EditorGUILayout.BeginVertical("window");
    7.             EditorGUI.PropertyField(new Rect(rect.x, rect.y, rect.width - 300, EditorGUIUtility.singleLineHeight),
    8.                 element.FindPropertyRelative("Prefab"), GUIContent.none);
    9.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300, rect.y, 50, EditorGUIUtility.singleLineHeight),
    10.                 element.FindPropertyRelative("BuyPrice"), GUIContent.none);
    11.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 50, rect.y, 50, EditorGUIUtility.singleLineHeight),
    12.                 element.FindPropertyRelative("SellPrice"), GUIContent.none);
    13.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 100, rect.y, 50, EditorGUIUtility.singleLineHeight),
    14.                 element.FindPropertyRelative("CookTime"), GUIContent.none);
    15.             // Position
    16.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 150, rect.y, 30, EditorGUIUtility.singleLineHeight),
    17.                 element.FindPropertyRelative("RotX"), GUIContent.none);
    18.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 180, rect.y, 30, EditorGUIUtility.singleLineHeight),
    19.                 element.FindPropertyRelative("RotY"), GUIContent.none);
    20.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 210, rect.y, 30, EditorGUIUtility.singleLineHeight),
    21.                 element.FindPropertyRelative("RotZ"), GUIContent.none);
    22.             // Rotation
    23.             EditorGUILayout.Space(30f);
    24.             rect.y += 2;
    25.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 150, rect.y + EditorGUIUtility.singleLineHeight, 30,
    26.                 EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("RotX"), GUIContent.none);
    27.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 180, rect.y + EditorGUIUtility.singleLineHeight, 30,
    28.                 EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("RotY"), GUIContent.none);
    29.             EditorGUI.PropertyField(new Rect(rect.x + rect.width - 300 + 210, rect.y + EditorGUIUtility.singleLineHeight, 30,
    30.                 EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("RotZ"), GUIContent.none);
    31.             EditorGUILayout.EndVertical();
    32.         };