I was wonder how I would have the reorderable list have different looks depending on what the enum list option is selected. The List has a enum list and a string and a gameobject. When the enum list is selected as “GameObject” I want it to only show the GameObject Box and when “Text” is selected only a Text box shows up. Is this possible to do?
SuperHB
2
I figured it out myself. This is how you do it:
list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
var element = list.serializedProperty.GetArrayElementAtIndex(index);
if (element.FindPropertyRelative("enum").enumValueIndex == 0) {
rect.y += 2;
EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("enum"), GUIContent.none);
EditorGUI.PropertyField(new Rect(rect.x + 65, rect.y, rect.width - 120, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("text"), GUIContent.none);
EditorGUI.PropertyField(new Rect(rect.x + rect.width - 50, rect.y, 50, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("keycode"), GUIContent.none);
} else {
EditorGUI.PropertyField(new Rect(rect.x, rect.y, 60, EditorGUIUtility.singleLineHeight), element.FindPropertyRelative("enum"), GUIContent.none);
}
};