I finally got a array handling with serialized properties working, but I need the same for generic lists. It comes down to to the question of “How to access List.Count and List[dataindex] when using FindProperty()” ???
Here’s my working array code so far:
void ArrayGUI(SerializedObject obj,string name)
{
int no = obj.FindProperty(name + ".Array.size").intValue;
EditorGUI.indentLevel = 3;
int c = EditorGUILayout.IntField("Size", no);
if (c != no)
obj.FindProperty(name + ".Array.size").intValue = c;
for (int i=0;i<no;i++) {
var prop = obj.FindProperty(string.Format("{0}.Array.data[{1}]", name, i));
EditorGUILayout.PropertyField(prop);
}
}
Resurrecting this old thread because I always forget the solution and it’s the first hit on Google;
In newer versions of Unity, the PropertyField now has an IncludeChildren flag - simply set that to true and your PropertyField will draw arrays like the default inspector.