- Home /
Why are the children of my Serialized Property not being drawn?
Hi all
I've been trying to use SerializedObject and SerializedProperty to draw some ScriptableObjects in the inspector:
SerializedObject serializedKvp = new SerializedObject(kvp);
SerializedProperty valuesListProperty = serializedKvp.FindProperty("m_Value");
SerializedProperty modifierProperty = valuesListProperty.GetArrayElementAtIndex(index);
EditorGUILayout.PropertyField(modifierProperty, true);
What I'm getting is this:
Firstly, I don't want the "Element 0" label, which I presume is Unity trying to be "helpful" because my property is a List index.
Secondly, I'm telling the PropertyField to draw the children and I'm not getting any. If I double click the PropertyField I get this in a new inspector:
So you can clearly see that the property has child properties.
Can anyone explain to me why this is happening and how I can improve it?
Thanks, Ves
Answer by VesuvianPrime · Aug 19, 2015 at 03:13 PM
This was a fundamental misunderstanding of how ScriptableObjects work. Since ScriptableObjects are their own asset, Unity doesn't bother recursing through them and instead draws an object field.
Your answer
Follow this Question
Related Questions
Error when trying to Serialize a field that is in a class 0 Answers
Change the fields on a object bound to a SerializedProperty via custom inspector? 1 Answer
Cannot convert serializedObject to float 1 Answer
Replicate "Apply" and "Revert" button functionality in ScriptableObject Editor Inspector 2 Answers
Custom Inspector: Using 'serializedObject' to access inherited members 1 Answer