In spite of it’s name, I cannot seem to set the colour of a dynamic material instance. Here is what I’m trying to do to accomplish this in the constructor for my actor class:
MeshComponent = CreateDefaultSubobject< UStaticMeshComponent >(
TEXT("MeshComponent") );
MeshComponent->SetMobility( EComponentMobility::Movable );
MeshComponent->SetStaticMesh( Mesh ); // Mesh is a UStaticMesh asset found earlier
UMaterialInstanceDynamic * DynamicMaterial =
MeshComponent->CreateAndSetMaterialInstanceDynamic( 0 );
// I want my colour to be emissive, but setting either of these has no effect.
DynamicMaterial->SetVectorParameterValue( FName("Color"),
FLinearColor( 1.0f, 0.0f, 0.0f ) );
DynamicMaterial->SetVectorParameterValue( FName("Emissive Color"),
FLinearColor( 1.0f, 0.0f, 0.0f ) );
// For good measure I tried setting it again, but no effect.
MeshComponent->SetMaterial( 0, DynamicMaterial );
I’ve tried creating the dynamic material with a parent material but then only the parent material’s properties are ever used. I just can’t seem to get any parameter setting to take affect. Any ideas on how to do this correctly? or if this is even possible?