Hello! I’ve got a problem with using materials from MobileStarterContent.
I used this C++ code to load Material:
WoodMat(TEXT("/MobileStarterContent/Materials/M_Wood_Pine.M_Wood_Pine"))
...
BlockMesh->SetMaterial(0, ConstructorStatics.WoodMat.Get());
But after I build this project in Visual Studio, I get message that /MobileStarterContent/Materials/M_Wood_Pine.M_Wood_Pine asset was not found. What I am doing wrong?
Thanks in advance!
Hello,
To get the correct asset reference, please right-click on the asset in Content Browser and click “Copy Reference”.
Thus, you’ll be able to paste it to the appropriate place in your code and load the asset:
static ConstructorHelpers::FObjectFinder<UMaterial> Material(TEXT("Material'/Game/MobileStarterContent/Materials/M_Wood_Pine.M_Wood_Pine'"));
VisibleMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("VisibleMesh"));
if (Material.Succeeded())
{
VisibleMesh->SetMaterial(0, Material.Object);
}
Hope this helped!
Good luck!
Problem was in using UMaterialInstance class instead of UMaterial. Thanks for code example