因为要在项目中使用UMG功能,所以找到项目中名称为 "项目名称.Build.cs" 文件,加入如下代码
创建一个Button的子类
生成的初始代码:
//CustomButton.h
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Components/Button.h"
#include "CustomButton.generated.h"
/**
*
*/
UCLASS()
class LEARNUE4CPP_API UCustomButton : public UButton
{
GENERATED_BODY()
};
// CustomButton.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "LearnUE4Cpp.h"
#include "CustomButton.h"
在上面代码的基础上修改后的代码:
//Custo