[UE4]用C++如何动态创建TextRender
keywords: [UE4]用C++如何动态创建TextRender
关键字:Runtime、TextRender、TextRenderActor
代码:
#include "Engine/TextRenderActor.h"
#include "Components/TextRenderComponent.h"
void ATopDownTestGameMode::BeginPlay()
{
Super::BeginPlay();
Text = GetWorld()->SpawnActor<ATextRenderActor>(ATextRenderActor::StaticClass(), FVector(0.f, 100, 170.f), FRotator(90.f, 180.f, 0.f));
Text->GetTextRender()->SetText(FText::FromString(TEXT("Dynamic Text")));
Text->GetTextRender()->SetTextRenderColor(FColor::Red);
Text->SetActorScale3D(FVector(5.f, 5.f, 5.f));
}