public void ArrayGUIoc<T>(WMG_List<T> observableCollection, string label, string name, SerializedObject serObj, EditorListOption options = EditorListOption.Default) { bool showListLabel = (options & EditorListOption.ListLabel) != 0; bool showListSize = (options & EditorListOption.ListSize) != 0; SerializedProperty list = serObj.FindProperty(name); if (showListLabel) { EditorGUILayout.PropertyField(list, new GUIContent(label)); EditorGUI.indentLevel += 1; } if (!showListLabel || list.isExpanded) { int prevSize = list.arraySize; if (showListSize) { EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size")); } // The size changed notify observableCollection of this change if (prevSize != list.arraySize) { if (Application.isPlaying) { list.serializedObject.ApplyModifiedProperties (); observableCollection.SizeChangedViaEditor(); } } for (int i = 0; i < list.arraySize; i++) { SerializedProperty prop = list.GetArrayElementAtIndex(i); if (prop.propertyType == SerializedPropertyType.String) { string prev = prop.stringValue; EditorGUILayout.PropertyField(prop); if (prev != prop.stringValue) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor(i); } } else if (prop.propertyType == SerializedPropertyType.Float) { float prev = prop.floatValue; EditorGUILayout.PropertyField(prop); if (prev != prop.floatValue) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor(i); } } else if (prop.propertyType == SerializedPropertyType.Color) { Color prev = prop.colorValue; EditorGUILayout.PropertyField(prop); if (prev != prop.colorValue) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor(i); } } else if (prop.propertyType == SerializedPropertyType.Vector2) { Vector2 prev = prop.vector2Value; EditorGUILayout.PropertyField(prop); if (prev != prop.vector2Value) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor(i); } } else if (prop.propertyType == SerializedPropertyType.ObjectReference) { UnityEngine.Object prev = prop.objectReferenceValue; EditorGUILayout.PropertyField(prop); if (prev != prop.objectReferenceValue) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor(i); } } else if (prop.propertyType == SerializedPropertyType.Boolean) { bool prev = prop.boolValue; EditorGUILayout.PropertyField (prop); if (prev != prop.boolValue) { list.serializedObject.ApplyModifiedProperties (); observableCollection.ValueChangedViaEditor (i); } } } } if (showListLabel) { EditorGUI.indentLevel -= 1; } }