I created custom inspector for my Journal class to display List<T>
as ReorderableList<T>
. To display class structure I wrote 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 be displayed like this:
[1: Name] [1: Picture]
[1: Description]
[2: Name] [2: Picture]
[2: Description]
But in result, "Description" of the first element overlapping with "Name" and "Picture" of the second element and so on.
And I can't find any way to increase ReorderableList
's element height. Setting rect.min
doesn't help
list.elementHeight = EditorGUIUtility.singleLineHeight * 2f;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With