I am trying to modify the elements in an array via a SerializedProperty. However, I cannot seem to figure out how to. I can increase the array size and such, but I can’t seem to directly access and modify an element in the array.
When it comes to single values, say a float, I can modify it as such:
SerializedProperty m_Speed;
public void OnEnable()
{
m_Speed = this.serializedObject.FindProperty("speed");
}
public override void OnInspectorGUI()
{
this.serializedObject.Update();
EditorGUILayout.PropertyField(m_Speed);
if(m_Speed.floatValue < 0)
{
//Prevents value from going below 0
m_Speed.floatValue = 0f;
}
this.serializedObject.ApplyModifiedProperties();
}
How can I do this with an array?