创建结构体
简单结构体
USTRUCT()
struct FMyFirstStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY()
FName Name = FName("");
UPROPERTY()
float exp = 0;
};
与蓝图交互结构体
USTRUCT(BlueprintType)
struct FMyFirstStruct
{
GENERATED_USTRUCT_BODY()
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Default")
FName Name = FName("");
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category="Default")
float exp = 0;
};
使用结构体
声明:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Default")
FMyFirstStruct FirstStruct;
在cpp里输出Struct的内容
UE_LOG(LogTemp, Warning, TEXT("FirstStructName: %s All"), *(FirstStruct.Name.ToString()));
UE_LOG(LogTemp, Warning, TEXT("FirstStructName %s All"), *(FirstStruct.Name.ToString()));
参考:【教程】UE4中结构体的使用:C++篇
|