What is UArrayProperty and how to use it?

I’ve been wanting to use KismetArrayLibrary’s GenericArray_Set function mostly because I don’t want to manually resize arrays (i.e. SizeToFit = true). One of the passed params is const UArrayProperty* ArrayProp. I understand this has something to do with Unreal’s property (reflection) system, but there appears to be no documentation anywhere on how to get any given array’s property.

As a simple example:



TArray<FVector> LocalVertices;
FVector MeshLocation = VisualisationMesh->GetComponentLocation();

    for (int32 i = FirstIndex; FirstIndex < LastIndex; ++i)
    {
        FVector Current = Points*; //Points is a parameter passed from elsewhere.
        UArrayProperty* ArrayProp = ?? // What goes here?
        UKismetArrayLibrary::GenericArray_Set(LocalVertices, ArrayProp, i - FirstIndex + 1, FVector(Current.X - MeshLocation.X, Current.Y - MeshLocation.Y, Current.Z - MeshLocation.Z), true);
    }


What do I replace “??” with?



for (int32 i = FirstIndex; FirstIndex < LastIndex; ++i)
{
    LocalVertices.Add(Points*);
}


Arrays are types with their own functions. You shouldnt be using the BP function library to do anything to them.

Calling Add() will add the element and resize the array if required - however resizing arrays is the slowest thing about them. Generally you should reduce the number of allocations you make by reserving space first:



// Preallocate space if required.
int32 Count = LastIndex - FirstIndex;
LocalVertices.Reserve(Count);

for (int32 i = FirstIndex; FirstIndex < LastIndex; ++i)
{
    LocalVertices.Add(Points*);
}