c++ and vertex color

I have a problem when I paint the vertex color in the editor. After painting I save, I close the editor and when I load the project I see that what I painted has not been saved.
This happens with the objects in the class that I created using the code I put below.
I’ve searched but can’t find anything about it and I don’t know how to make it save or load it if it’s saved.

for (index = 0; index < quantity; index++)
         constructArray.Add(NewObject<UStaticMeshComponent>(outer, UStaticMeshComponent::StaticClass(), *tempText, EObjectFlags::RF_Public));
         constructArray[index]->SetRelativeLocation(FVector((index)*size, 0, 0));

Are you running that code in the Constructor?
In the Constructor you need to Call ConstructDefaultSubject (there are some similar functions, search for “construct” in UObject class) instead of NewObject.

The Array might also be a Problem

Thanks for the input.

I tried with CreateDefaultSubobject <UStaticMeshComponent> (TEXT (“Trim”)); but vertex paint continues to disappear when exiting the editor and re-entering. The truth is that I don’t know why. With blueprints or adding staticmesh directly it works as it should.

The complete code is this:

     // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    PrimaryActorTick.bCanEverTick = false;
    Root = CreateDefaultSubobject<USceneComponent>(TEXT("Root"));
    RootComponent = Root;
    trimComponent = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Trim"));

void ATrims::OnConstruction(const FTransform& Transform)
    static const FString ContextString(TEXT("TrimSearch"));
    FTrimMesh* TrimStruct;
    FString tempName;

    if (TrimAData) {
        tempName = *FString::FromInt(static_cast<uint8>(Trim));
        TrimStruct = TrimAData->FindRow<FTrimMesh>(FName(*tempName), ContextString, true);

        if (TrimStruct)
            //trimComponent = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass(), TEXT("Trim"), EObjectFlags::RF_Public);

Partially resolved.
If I define the variable trimComponent with UPROPERTY (VisibleAnywhere), it works.
Now I need to find out how to do it so I can define how I had it with a variable “Quantity” to draw several objects in a row.
I did this with NewObject, but from what I’ve been able to see, it creates an instance and doesn’t save the vertex color that are changed in the editor.

Not working with Vertex Coloring of placed objects. But the color data should be saved to the level data. So the level needs to now which component it needs to reapply that data to. Pointer do not work here as those can’t be saved. So the levels only options is to reference the mesh via the property name of the component, but can’t handle arrays (I assume).

For sure it is not impossible, but might need modifications to the engine.