任务:使用UMG创建UI,并将其显示在游戏界面
第一步:创建相应的控件蓝图类并编辑
第二步、以PlayController为基类,创建新的C++类,命名为MainPlayerController,在该类中实现调用UI
MainPlayerController.h代码如下:
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "MainPlayerController.generated.h"
/**
*
*/
UCLASS()
class LEARNTEST_API AMainPlayerController : public APlayerController
{
GENERATED_BODY()
public:
//用户控件类族,可在蓝图中编辑
UPROPERTY(EditAnywhere,BlueprintReadWrite)
TSubclassOf<UUserWidget>