Hi,
I tried to change a actor material at runtime, but issue.
As below image, this actor is fbx object and import at runtime,
the left white one is import fine, and right one is changed material but issue
the code is:
FString name = GotActor->GetName();
if (name.StartsWith("FBXMeshActor"))
{
TArray<UProceduralMeshComponent*> ProChildren;
GotActor->GetComponents(ProChildren);
for (int g = 0; g < ProChildren.Num(); g++)
{
UMaterialInterface* MeshMat;
MeshMat = ProChildren[g]->GetMaterial(0);
UMaterialInstanceDynamic* DynaMat = UMaterialInstanceDynamic::Create(MeshMat, this);
DynaMat->SetVectorParameterValue(TEXT("BaseColor"), FLinearColor(1.0f, 0.0f, 0.0f, 1.0f));
ProChildren[g]->SetMaterial(0, DynaMat);
}
}
My material parameter:
What’s wrong?
Please help
Thank you