Currently what I am doing this but it doesnt work, it prints the correct size of the serialized array but not the content, how can I do it?
Debug.Log("Size: " + l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("down").arraySize);
for (int i = 0; i < l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("down").arraySize; i++) {
Debug.Log(l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("down").GetArrayElementAtIndex(i));
}
It depends on what’s inside “down”. GetArrayElementAtIndex just returns another SerializedProperty, so you need to access what’s inside that SerializedProperty to print it. Suppose down is a a List of GameObjects: public List<GameObject> down;, you could do it like this:
SerializedProperty downProperty = l.serializedProperty.GetArrayElementAtIndex(l.index).FindPropertyRelative("down");
Debug.log(downProperty.arraySize);
for (int i = 0; i < downProperty.arraySize; i++;)
{
Debug.Log(downProperty.GetArrayElementAtIndex(i).objectReferenceValue);
}
You can find how to get the value of different types of properties in this doc page. All the members that have the word “value” in them serve to access different types of data. Although, if down is an array of custom structs or classes, you’ll need to do a bit more than that.