.h
UPROPERTY(VisibleAnywhere, BlueprintReadWrite)
UTextRenderComponent* TRC;
.cpp
USquareComponent::USquareComponent()
{
ConstructorHelpers::FObjectFinder<UStaticMesh> BasicPlane(TEXT("StaticMesh'/Engine/BasicShapes/Plane.Plane'"));
ConstructorHelpers::FObjectFinder<UFont> TextRenderFont(TEXT("Font'/Game/AuraTD/Fonts/Aldrich-Regular_Font.Aldrich-Regular_Font'"));
PlaneSMC = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Plane"));
PlaneSMC->SetupAttachment(this);
PlaneSMC->SetCastShadow(false);
if (BasicPlane.Succeeded())
{
PlaneSMC->SetStaticMesh(BasicPlane.Object);
PlaneSMC->OnBeginCursorOver.AddDynamic(this, &USquareComponent::OnMouseOver);
PlaneSMC->SetRelativeScale3D(FVector(0.94f));
PlaneSMC->SetRelativeLocation(FVector(0.f, 0.f, 0.5f));
}
TRC = CreateDefaultSubobject<UTextRenderComponent>(TEXT("Id"));
TRC->SetupAttachment(PlaneSMC);
TRC->SetRelativeRotation(FRotator(90.f, 0.f, 180.f));
TRC->SetRelativeLocation(FVector(0.f, 0.f, 1.f));
TRC->SetHorizontalAlignment(EHorizTextAligment::EHTA_Center);
if (TextRenderFont.Succeeded())
{
TRC->SetFont(TextRenderFont.Object);
TRC->SetTextRenderColor(FColor::Black);
}
}
If I comment out TRC->SetFont(TextRenderFont.Object);
then I get actual text. I also tried offline fonts from 10px up to 72px.