Download

Property Specifiers for Object within TArray

I have the following declaration for a StaticMesh array.


UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite)    TArray<UStaticMeshComponent*> VisualMeshComp;

Then I have some function to create the corresponding mesh components;


    
    std::string    prefix = "SuspComp_";
    for (int i = 0; i < WheelPairs; i++)
    {
        num = std::to_string(i);
        name = prefix + num
        VisualMeshComp.Add(CreateDefaultSubobject<UStaticMeshComponent>(ANSI_TO_TCHAR(name.c_str())));
    }


When I access the corresponding Blueprint Class the components are created as expected, however I can’t access the ‘details’ tab of the Static Meshes.

Is there a way to enable editing the detail properties from the blueprint editor?



VisibleDefaultsOnly


Is Read-Only. If you want users to modify them then you need:



EditDefaultsOnly


You can also add in “EditFixedSize” if you don’t want them to be able to add/remove entries from the array.

Also, avoid STL containers like std::string when possible, just use FText or FString, they have all printf and such in there.



for(int i =0; i < WheelPairs; ++i)
{
    VisualMeshComp.Add(CreateDefaultSubobject<UStaticMeshComponent>(FString::Printf(TEXT("SuspComp_%d"), i));
}