Hi,
I couldn’t find any resource or questions asked about this. Is it possible to create material parameters dynamically and assign it to a material(or a dynamic material instance) during runtime through C++?
For eg. something like this :
// Let's say you have a pawn with a static mesh component and you create a dynamic instance of it;s material at index 0 like this
UMaterialInstanceDynamic* DynamicMatInst = StaticMeshComponent->CreateDynamicMaterialInstance(0);
// Usually we create a material param before hand in Editor (Let's call it 'VecParam') and assign a value to it like this
DynamicMatInst->SetVectorParameterValue(FName("VecParam"), FLinearColor::Red);
// But, I don't want to create a param before hand, but rather create a param for an existing material and assign it dynamically through material's dynamic instance. Something like this?
DynamicMatInst->GetMaterial()->EmissiveColor->CreateParam<VectorParam>(FName("VecParam"), FLinearColor::Red);
Appreciate any suggestions or inputs.
Cheers!