Reflection: Set element within FArrayProperty

as the title says I’m looking for a way to set values within an array through reflections.
More specifically I know how to set an FProperty value but I’m unsure how to get a reference to a particular FProperty within an FArrayProperty.

Let’s say I wanna always chanbge the last element in the array, and only the last, how can I get a pointer to the FProprerty that represents that last element in order to set its value?


So if I remember correctly, array properties are actually just a single property where you additionally use an index to access the particular element you want. Every type of property supports using this index!

So (in pseudocode) it’s not like:

ElementProperty = ArrayProperty.Get(Index)
ElementProperty.Set(Object, Value)

It’s like:

ArrayProperty.Set(Object, Value, Index)

I can’t remember the actual reason you’d use FArrayProperty. You can get the array dimension from any FProperty's ArrayDim field. For getting/setting values, CastField to FObjectProperty, FBoolProperty, FFloatProperty, FIntProperty, or whatever, and pass your index to SetPropertyValue_InContainer(Object, Value, Index).

1 Like