Why do I get a link error when setting parameter values on a material parameter collection instance?

Hi,

I’m writing a system that updates some parameter values in my material parameter collection, but when I compile I get a link error for SetScalarParameterValue.

SetScalarParameterValue is tagged ENGINE_API in UMaterialInstanceDynamic but not in UMaterialParameterCollectionInstance. Is that intentional?

Should I only be changing parameter collection values through blueprints?

Thanks,

Ryan.

Anyone else have this problem?

Yup - just hit the same problem. There are setters, but linker errors even when defining dependencies on the Engine module

Hi,

What is the exact error message you receive?

I’m not at my dev machine at the moment, will post an actual output in the morning. But it’s just the typical VS linker text of SetScalarParameterValue not being found in any linked libraries. It’s not in the Engine module. Is there a submodule of Engine/Material or something like that?

Yeah, the error is just a standard symbol not found link error. I added ENGINE_API to the functions equivalent to UMaterialInstanceDynamic and rebuilt the engine. I’ll submit the change to Git and put in a pull request.

The functions that the blueprint system uses to set parameters in a UMaterialParameterCollectionInstance are completely exposed for use by game module code (i.e. they’re exported from the engine with ENGINE_API). So I’ve changed my code to use this instead:

UKismetMaterialLibrary::SetScalarParameterValue(this, Collection, ParameterName, ParameterValue);

SetScalarParameterValue is a static ENGINE_API function in KismetMaterialLibrary.h

Hmm… so I was just reviewing my change to submit to Git and realised I could fix this without an engine change. See my answer below.

Error 1 error LNK2019: unresolved external symbol “public: bool __cdecl UMaterialParameterCollectionInstance::SetScalarParameterValue(class FName,float)” (?SetScalarParameterValue@UMaterialParameterCollectionInstance@@QEAA_NVFName@@M@Z) referenced in function “public: virtual void __cdecl AStereoVideoPlayerController::PreRenderView_RenderThread(class FSceneView &)” (?PreRenderView_RenderThread@AStereoVideoPlayerController@@UEAAXAEAVFSceneView@@@Z) F:\StereoVideo\Intermediate\ProjectFiles\StereoVideoPlayerController.cpp.obj StereoVideo

Hi,

I just wanted to confirm that you are no longer experiencing this issue. I am marking this question as resolved, but if you still need any additional help, please feel free to reopen the question.