1. 创建
UENUM(BlueprintType)
enum class EDamageType : uint8
{
DT_Normal UMETA(DisplayName = "Normal"),
DT_Fire UMETA(DisplayName = "Fire"),
DT_Ice UMETA(DisplayName = "Ice"),
};
UCLASS()
class EXERCISE_API AENUMTEST : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AENUMTEST();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
};
注意:
1. 结构体最好声明在继承了Actor的类里
2. UMETA(DisplayName)表示显示在蓝图里的名称
2. 在蓝图里的应用

本文介绍如何在继承自AActor的类中使用UENUM创建枚举结构EDamageType,包括Normal、Fire和Ice类型,并展示如何在AENUMTEST类中设置默认值、BeginPlay和Tick方法的应用,以及在蓝图中的显示和操作。
673

被折叠的 条评论
为什么被折叠?



