How to change material for a mesh in cpp?

The way I generally do it is: declare the material in .h (this is in case you create blueprints based on the cpp class:

UPROPERTY(EditAnywhere)
UMaterialInterface* MaterialRef;

Set the reference in the blueprint, and then you can use it in your cpp.

1 Like