I can not add a material from c ++

Hello!

I can not add a material from c ++

my code…

**

the static mesh if it is loaded but the material does not

**

**

result:

**

253561-captura2.png

**

the material does not load, what am I doing wrong

**

It’s not a Material Instance, it’s a Material. So try changing UMaterialInstance to UMaterial.

@erikdubbelboer ok friend…

now if you add it in the editor, but when compiling the materials are not reflected

try creating an instance of the material like this:

and changing my code like this:

it does not work, materials are not reflected

253570-mate.png

Now I realized that if I change the component from “UInstancedStaticMeshComponent” to “UStaticMeshComponent” if it works, but I need them to be instances. “UInstancedStaticMeshComponent”

Materials have an attribute “Used With InstancedStaticMeshes”
You have to toggle that to true in the editor and then it should work.

1 Like

@erikdubbelboer thank you very much, that was all