Here is this basic code, that worked in previous versions of UE4, anyway it still compiles without any problem.
//get the material itself
UMaterialInstanceConstant *FoundMaterial = FindObject<UMaterialInstanceConstant>(ANY_PACKAGE, FixedMaterialName.GetCharArray().GetData());
//if the material exists add it
if (FoundMaterial != nullptr)
FName MaterialFName = FName(“A”);
smat.ImportedMaterialSlotName = MaterialFName;
smat.MaterialSlotName = MaterialFName;
if I don’t add the smat to StaticMaterials everything looks ok (but obviously I have no materials applied), notice that also it doesn’t crash on adding it but when I try to open that StaticMesh in the editor or if I place it in the viewport.
Any tip on this?
PS. note that I’m referring to UStaticMesh not a component neither an actor.