#Btw I need not the string value but the

1 messages · Page 1 of 1 (latest)

blissful wyvern
#

So I need to use another approach, not the property drawer?
I need to add a new instance to the list by clicking the button.

hollow oar
hollow oar
#

And then don't forgot to call ApplyModifiedProperties on the SerializedObject.

blissful wyvern
# hollow oar ```cs SerializedProperty array = property.FindPropertyRelative("StingsList"); S...

InsertArrayElementAtIndex returns void.
I'm trying like this:

 property.FindPropertyRelative("StatModifiers").InsertArrayElementAtIndex(0);
                DamageModifier elem = property.GetArrayElementAtIndex(0) as DamageModifier;
                elem = new DamageModifier();

but it says annot convert type 'UnityEditor.SerializedProperty' to 'DamageModifier' via a built-in conversion to my "as DamageModifier" conversion.

hollow oar
#

How is DamageModifier serialized? As a normal serialized class/struct or with SerializeReference?

#

And yeah sorry, I forgot it doesn't return the new element. You'll have to add it and then get it with GetArrayElementAtIndex(array.arraySize - 1)

#

Or 0 if you want to add it to the start

blissful wyvern
hollow oar
#

You can't cast a SerializedProperty to anything. Everything has to be set through its properties.

For SerializeReference, that would be through the managedReferenceValue property.