UE C++ 蓝图 数据结构
时间: 2023-11-14 14:01:06 浏览: 61
UE C++蓝图数据结构是通过结构体和类来定义的。可以通过将现有的蓝图结构体引用,手动替换成新的C++结构体变量来实现。首先,在.h文件中声明结构体,并使用USTRUCT(BlueprintType)宏进行标记。然后使用UPROPERTY宏定义结构体的成员变量。接下来,在.cpp文件中使用GENERATED_BODY()宏生成结构体的代码。同样的,可以创建一个继承于UObject的C++类来定义蓝图数据结构。
示例代码如下:
```cpp
// .h文件
#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "QuestInfo.generated.h"
USTRUCT(BlueprintType)
struct BLUEPRINTSTOCPP_API FQuestInfo
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FName QuestId;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 Progress;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ProgressTotal;
};
UCLASS()
class BLUEPRINTSTOCPP_API UQuestInfo : public UObject
{
GENERATED_BODY()
};
```