How can I use SetMaterialUsage()?

I don’t understand the parameters SetMaterialUsage takes. I’m using Instanced static meshes so I need to toggle the “Use with Instanced Static Meshes” toggle so that my materials render on the instances. I’m trying to do this in code and not through the editor.

SetMaterialUsage
(
bool& bNeedsRecompile,
const EMaterialUsage Usage,
const bool bSkipPrim
)

Do I need recompile, if so how do I set the first parameter? Where are the EmaterialUsage flags listed? and what does bSkipPrim do?

Also is there a way to set bUseWithStaticMesh directly or do I need to use SetMaterialUsage?

SetMaterialUsage(true, MATUSAGE_InstancedStaticMeshes, false); This gives me red line under the first parameter. Error says “initial value of reference to non-const must be an lvalue”. What does this mean and how can I set this first parameter correctly?

The bNeedsRecompile parameter is a function output that’s there to inform you whether the material was recompiled when the usage changed. I don’t believe bSkipPrim actually does anything and you can ignore it.

You can call the function like this

bool bNeedsRecompile;
Material->SetMaterialUsage(bNeedsRecompile, MATUSAGE_InstancedStaticMeshes);

You can find the rest of the usage flags in MaterialInterface.h, line 18