void ATileBase::SetColor(FLinearColor NewColor)
{
UMaterialInstanceConstant* MaterialInstance = Cast<UMaterialInstanceConstant>(StaticLoadObject(UMaterialInstanceConstant::StaticClass(), nullptr, TEXT("/Game/Level/Play/Grid/TileMatInst.TileMatInst")));
if (MaterialInstance)
{
UMaterialInstanceDynamic* DynamicMaterialInstance = UMaterialInstanceDynamic::Create(MaterialInstance, this);
if (DynamicMaterialInstance)
{
DynamicMaterialInstance->SetVectorParameterValue(FName("Color"), NewColor);
PlaneMeshComponent->SetMaterial(0, DynamicMaterialInstance);
}
}
else
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, FString::Printf(TEXT("TileMatInst Not Found")));
}
Path
/Script/Engine.MaterialInstanceConstant’/Game/Level/Play/Grid/TileMatInst.TileMatInst’
Include in a packaged build
PC
Android
It is reported that it can’t find only the material instance file, while other assets have no problem. What should I do?
Thanks.