Material Parameter Collections and Code?

Hi. Just in case someone wonder how directly load de collection. But keep in mind the above warning about cooked content.




// Class variable
UMaterialParameterCollection* collection;
...
// Inside constructor:
...
ConstructorHelpers::FObjectFinder<UMaterialParameterCollection> objectType(TEXT("/Game/Project/Materials/MPC_Params"));
if (objectType.Succeeded())
{
collection = objectType.Object;
}
...
// when needed
UMaterialParameterCollectionInstance * pci = GetWorld()->GetParameterCollectionInstance(collection);
if (pci)
{
bool found = pci->SetVectorParameterValue(FName("ParamName"), FLinearColor(400, 400, 0, 0));
...
}
}

3 Likes