C++ TArray elements not showing up in BP editor

I’ve been trying to figure this out for hours but can’t understand what’s the issue.
Basically I have a TArray in C++ and it’s populated in OnConstruction function:

.h
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Properties")
TArray<FPropMaterialData> meshes;

.cpp
void AMasterObject::OnConstruction(const FTransform& Transform)
{
	Super::OnConstruction(Transform);

	TArray<UActorComponent*> temp = Mesh->GetOwner()->GetComponentsByTag(UActorComponent::StaticClass(), "MESH");

	for (int32 i = 0; i != temp.Num(); ++i)
	{
		FPropMaterialData prop;
		meshes.Add(prop);
...

My blueprint is derived from a C++ class that is derived from another custom C++ class (AMasterObject, AActor as parent)
The array shows up fine in Blueprint editor and when placed into the world. But in the blueprint editor the array is empty; and when I place the actor into the world and check its details the array shows populated there.
Everything else done in ‘OnConstruction’ works fine in BP editor, such as changing material etc.

I’ve tried re-creating the blueprint from scratch, and many random fixes I found online but nothing worked.

Any idea why the array shows populated in the world but not in BP editor? (in details panels)

@NukeCorruption in the documentation you can see
AActor::OnConstruction => Called when an instance of this class is placed (in editor) or spawned.

Only CDO will be called with the bp editor. You would need to put this logic in

void AMasterObject::AMasterObject(){
// here
}

But for that to work all components with the tag “MESH” would need to be create in c++ in the CDO so that they can be accessed during the running of the function.

also don’t forget to empty your TArray meshes before you start filling it.

I have done that too and MESH tag is set in C++ side constructor too, didn’t work at all. But I’ll try again, maybe I missed something obvious

EDIT: That did it, not sure what I did wrong last time but now it works. Thanks!

Question though, why does creating dynamic material instance and setting material parameters work fine in OnConstructor in BP editor if it’s only active when “placed (in editor) or spawned”?

Perhaps it’s a matter of when the ui for the details panel is updated?

This is how I set it up:

AMasterObject::AMasterObject()
...
static ConstructorHelpers::FObjectFinder<UMaterial> MAT(TEXT("Material'/Game/Materials/Basic/M_Color.M_Color'"));

if (MAT.Object != nullptr)
{
	mat = MAT.Object;
}
...

void AMasterObject::OnConstruction(const FTransform& Transform)
{
	Super::OnConstruction(Transform);

	TArray<UActorComponent*> temp = Mesh->GetOwner()->GetComponentsByTag(UActorComponent::StaticClass(), "MESH");

	for (int32 i=0;i!=temp.Num();++i)
	{
		UMasterRootMesh* tempMesh = Cast<UMasterRootMesh>(temp[i]);
		if (tempMesh != nullptr)
		{
			TArray<UMaterialInterface*> mats = tempMesh->GetMaterials();

			for (int32 k=0;k!=mats.Num();++k)
			{
				UMaterialInstanceDynamic* mat_inst = UMaterialInstanceDynamic::Create(mat, tempMesh->GetOwner());
				tempMesh->SetMaterial(k, mat_inst);

				mat_inst->SetVectorParameterValue("Color", FLinearColor(FMath::FRandRange(0.0f, 1.0f), FMath::FRandRange(0.0f, 1.0f), FMath::FRandRange(0.0f, 1.0f)));
				mat_inst->SetScalarParameterValue("Metallic", FMath::FRandRange(0.0f, 1.0f));
				mat_inst->SetScalarParameterValue("Roughness", FMath::FRandRange(0.0f, 1.0f));
			}
		}
	}
}

Outcome: random color/etc everytime I click “Compile” or move any of the meshes

But anyway this was solved so thanks, just curious about that