# C++ TArray elements not showing up in BP editor

**URL:** <https://forums.unrealengine.com/t/c-tarray-elements-not-showing-up-in-bp-editor/686207>\
**Category:** C++\
**Tags:** unreal-engine, question, UE4-27, Blueprint, CPP\
**Created:** [November 7, 2022, 10:57pm UTC](https://forums.unrealengine.com/t/c-tarray-elements-not-showing-up-in-bp-editor/686207 "2022-11-07T22:57:20Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![NukeCorruption](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NukeCorruption](https://forums.unrealengine.com/u/NukeCorruption)\
**Post date:** [November 8, 2022, 1:24pm UTC](https://forums.unrealengine.com/t/c-tarray-elements-not-showing-up-in-bp-editor/686207/5 "2022-11-08T13:24:32Z")

</div>

This is how I set it up:

```auto
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

 ![material](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/6/7/d67a9ca7a3f0687067b1d25becd57b53a0cd3992.png)

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

---

_[View the full topic](https://forums.unrealengine.com/t/c-tarray-elements-not-showing-up-in-bp-editor/686207)._
