UE4 屏幕上显示文字

// 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里面设置

你可能感兴趣的:(UE4)