GetAllScalarParameterNames returns parameters in functions but GetScalarParameterValue does not

When using the following code on a material that has function that as a scalar parameter node in it, the array contains the name of this parameter (as you might expect);

TArray<FGuid> GUIDs;
TArray<FName> DisplacementScalarParameters;
Material->GetAllScalarParameterNames(DisplacementScalarParameters, GUIDs);

However, if you later use this parameter name to get the value, it cannot find it:

Material->GetScalarParameterValue(ParameterName, ScalarParameterValue);

This is because GetAllScalarParameterNames checks all UMaterialExpressionMaterialFunctionCall expression nodes in addition to al UMaterialExpressionScalarParameter expression nodes.

However, when we call GetScalarParameterValue we only look for UMaterialExpressionScalarParameter expression nodes, so the nested parameters are not found.

I suppose the fix for this is to adjust the GetScalarParamterValue to either search function nodes or perhaps just to call the GetAll… and filter by the name. If I get some time I’ll create a pull request with this fixed in the later way.