Hi!
I’m using Unreal 5.3.2 with C++.
I’m using the SM_Cube_01 from VREditor content:
This cube is using the MI_Cube_01 material instance:
Which have a Vector parameter called GlowColor that I want to change in C++. To do it, I have this code:
void ATFallingBlockActor::SetStaticMeshColour(FLinearColor CubeColour)
{
TObjectPtr<UMaterialInstance> Mat_Inst = Cast<UMaterialInstance>(StaticMesh->GetMaterial(0));
if (Mat_Inst)
{
UE_LOG(LogTemp, Warning, TEXT("BuildAddBlock"));
FMaterialParameterInfo ParameterInfo(FName("GlowColor"));
Mat_Inst->SetVectorParameterValueInternal(ParameterInfo, CubeColour);
}
}
But it doesn’t work because SetVectorParameterValueInternal
is a protected method.
I did it with Blueprint, and it is a lot of easier:
How can I do it C++?
Thank you.