[C++] Make Dynamic Material Get Parameters instead of Setting them

Hi,

Is it possible to make the Dynamic Material Instance Get the parameters instead of Setting them?

I already know how to set parameters and I already know Parameter Collection.

I have a different problem that I explain in this post:

Thanks.

1 Like

float OutValue = 0;
YourMaterialInstanceRef->GetScalarParameterValue(FName(TEXT(“ParmeterNameHere”), OutValue);

Same for the other Parameter types:

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetScalarParameterValue/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetVectorParameterValue/index.html

https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Materials/UMaterialInstance/GetTextureParameterValue/index.html

If you want to get Values of a Collection:

float OutValue = 0;
UMaterialParameterCollectionInstance* Instance = GetWorld()->GetParameterCollectionInstance(CollectionRef); //UMaterialParameterCollection*
bool bFoundParameter = Instance->GetScalarParameterValue(FName(TEXT("ParmeterNameHere"), OutValue);

Same for GetVectorParameterValue()

Make sure to check your Pointers before accessing them I left out the checks for simplicity

Sorry for the late reply.

Thanks for your answer. But I think I didn’t explain myself.

I need to have a set of Dynamic Material Instance that use a Parameter Collection.

An example is a character that has 20 Dynamic Material Instances of which 8 of them use ParameterCollectionA and 14 of them use ParameterCollectionB and 4 of the Dynamic Material Instance don’t use neither of those.

At the same time, each Dynamic Material Instance might not use all the parameters of the ParameterCollection.

Can be multiple instances of the characters and each character is responsible to set their ParameterCollections.

How can I solve that?

Can you please check my link? I have same issue with GetVectorParameterValue

tnx