My apologies but I’m so close, my super ghetto solution:
using UnityEditor;
using UnityEngine;
using System;
[Flags]
public enum EditorListOption {
None = 0,
ListSize = 1,
ListLabel = 2,
ElementLabels = 4,
Buttons = 16,
Toggles = 16,
Default = ListSize | ListLabel | ElementLabels,
NoElementLabels = ListSize | ListLabel,
All = Default | Buttons
}
public static class EditorList {
private static GUIContent
buttonContent = new GUIContent("+");
private static GUILayoutOption miniButtonWidth = GUILayout.Width(20f);
public static void Show (SerializedProperty list, EditorListOption options = EditorListOption.Default) {
if (!list.isArray) {
EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
return;
}
bool
showListLabel = (options & EditorListOption.ListLabel) != 0,
showListSize = (options & EditorListOption.ListSize) != 0;
if (showListLabel) {
EditorGUILayout.PropertyField(list);
EditorGUI.indentLevel += 1;
}
if (!showListLabel || list.isExpanded) {
SerializedProperty size = list.FindPropertyRelative("Array.size");
if (showListSize) {
EditorGUILayout.PropertyField(size);
}
if (size.hasMultipleDifferentValues) {
EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
}
else {
ShowElements(list, options);
}
}
if (showListLabel) {
EditorGUI.indentLevel -= 1;
}
}
private static void ShowElements (SerializedProperty list, EditorListOption options) {
bool
showElementLabels = (options & EditorListOption.ElementLabels) != 0,
showButtons = (options & EditorListOption.Buttons) != 0;
for (int i = 0; i < list.arraySize; i++) {
if (showButtons) {
EditorGUILayout.BeginHorizontal();
}
if (showButtons) {
ShowButtons(list, i);
EditorGUILayout.EndHorizontal();
}
}
if (showButtons && list.arraySize == 0 && GUILayout.Toggle(false,buttonContent, EditorStyles.miniButton)) {
list.arraySize += 1;
}
}
private static void ShowButtons (SerializedProperty list, int index) {
if (GUILayout.Toggle(true, buttonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) {
//list.MoveArrayElement(index, index + 1);
}
if (GUILayout.Toggle(true, buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true, buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true, buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true, buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
if (GUILayout.Toggle(true,buttonContent, EditorStyles.miniButtonRight, miniButtonWidth)) {
//list.InsertArrayElementAtIndex(index);
}
}
}
using UnityEditor;
using UnityEngine;
[CustomEditor(typeof(ListTester)), CanEditMultipleObjects]
public class ListTesterInspector : Editor {
public override void OnInspectorGUI () {
serializedObject.Update();
EditorList.Show(serializedObject.FindProperty("bools"), EditorListOption.Toggles | EditorListOption.ListLabel);
EditorList.Show(serializedObject.FindProperty("notAList"));
serializedObject.ApplyModifiedProperties();
}
}