My actor constructor code looks like this:
static ConstructorHelpers::FObjectFinder<UMaterial> material(TEXT("Material'/Game/Materials/M_Rock'"));
PrimaryActorTick.bCanEverTick = true;
m_mesh = CreateDefaultSubobject<UProceduralMeshComponent>(TEXT("ProceduralMesh"));
m_material = material.Object;
RootComponent = m_mesh;
In BeginPlay()
I call _CreateMesh()
, the end of which looks like this:
// I don't want colours.
m_mesh->CreateMeshSection(section,
vertices,
triangles,
normals,
uvs,
TArray<FColor>(),
tangents,
true);
m_mesh->SetMaterial(section, m_material);
The mesh displays, but there is no texture or material. Previously I was using another texture from the template level, and it worked fine. At first I thought the problem was that the material and textures (which I copied from Unreal Engine samples into my own Content tree) were not being cooked, but I added a simple actor with a spherical static mesh and applied the same material, and that works fine.
Can anyone help?