private static void ShowElements(SerializedProperty list, EEditorListOption options) { bool showElementLabels = (options & EEditorListOption.ElementLabels) != 0, showButtons = (options & EEditorListOption.Buttons) != 0; for (int i = 0; i < list.arraySize; i++) { if (showButtons) { EditorGUILayout.BeginHorizontal(); } var element = list.GetArrayElementAtIndex(i); if (showElementLabels) { EditorGUILayout.PropertyField(element, new GUIContent(element.FindPropertyRelative("name").stringValue), true); } else { EditorGUILayout.PropertyField(element, GUIContent.none, true); } if (showButtons) { ShowButtons(list, i); EditorGUILayout.EndHorizontal(); } } if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton)) { list.arraySize += 1; } }
public static void Show(SerializedProperty list, EEditorListOption options = EEditorListOption.Default) { bool showListLabel = (options & EEditorListOption.ListLabel) != 0, showListSize = (options & EEditorListOption.ListSize) != 0; if (showListLabel) { EditorGUILayout.PropertyField(list); EditorGUI.indentLevel += 1; } if (!showListLabel || list.isExpanded) { if (showListSize) { EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size")); } ShowElements(list, options); } if (showListLabel) { EditorGUI.indentLevel -= 1; } }