UE4 螢幕上顯示文字
阿新 • • 發佈:2018-12-14
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/HUD.h" #include "MyHUD.generated.h" /** * */ UCLASS() class PACMAN_API AMyHUD : public AHUD { GENERATED_BODY() public: UPROPERTY(EditAnywhere,BluePrintReadWrite,Category=HUDFont) UFont* HUDFont; //每一幀都會呼叫 virtual void DrawHUD() override; };
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyHUD.h"
#include "Engine/Canvas.h"
void AMyHUD::DrawHUD()
{
DrawText(TEXT("Welcome To Game\n"),FColor::White,Canvas->SizeX/2.0f-150,Canvas->SizeY/2.0f-100,HUDFont);
}
建立基於這個類的藍圖類,然後再GameMode的HUD裡面設定