#include "Components/TextRenderComponent.h" //声明 /** Text component for the score */ UPROPERTY(Category = Grid, VisibleDefaultsOnly, BlueprintReadOnly, meta = (AllowPrivateAccess = "true")) class UTextRenderComponent* ScoreText; // Create static mesh component ScoreText = CreateDefaultSubobject<UTextRenderComponent>(TEXT("ScoreText0")); ScoreText->SetRelativeLocation(FVector(200.f,0.f,0.f)); ScoreText->SetRelativeRotation(FRotator(90.f,0.f,0.f)); ScoreText->SetText(FText::Format(LOCTEXT("ScoreFmt", "Score: {0}"), FText::AsNumber(0))); ScoreText->SetupAttachment(DummyRoot); // Update text ScoreText->SetText(FText::Format(LOCTEXT("ScoreFmt", "Score: {0}"), FText::AsNumber(Score)));
其他显示方式:https://blog.csdn.net/zhengliuguo/article/details/81370156