How to change the height of a ReorderableList element in Inspector view

I created a custom inspector for my log class to display List<T>how ReorderableList<T>. To display the structure of the class, I wrote the following code:

private ReorderableList list;

private void OnEnable()
{
            list.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                rect = new Rect(rect.x, rect.y, rect.width, rect.height * 2);
                var element = list.serializedProperty.GetArrayElementAtIndex(index);
                rect.y += 2;
                EditorGUI.PropertyField(
                    new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("Name"), GUIContent.none);
                EditorGUI.PropertyField(
                    new Rect(rect.x + 100, rect.y, rect.width - 100, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("Image"), GUIContent.none);
                EditorGUI.PropertyField(
                    new Rect(rect.x, rect.y + EditorGUIUtility.singleLineHeight + 2f, rect.width, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("Description"), GUIContent.none);
            };

I expected it to display as follows:

[1: Name] [1: Picture]
[1: Description]
[2: Name] [2: Picture]
[2: Description]

But as a result, the "Description" of the first element overlaps with the "Name" and "Picture" of the second element and so on.

enter image description here

And I can not find a way to increase the height of the element ReorderableList. Setup rect.mindoes not help

+4
source share
1 answer
list.elementHeight = EditorGUIUtility.singleLineHeight * 2f;
+3
source

All Articles