for anyone with the same issue.
English Version
- add a new *.h file
- add the following code
#include "CoreMinimal.h" USTRUCT(BlueprintType) struct FMyNewStruct { GENERATED_BODY() };
- Note: Struct name start with F
- Note: GENERATED_BODY is required
- Build Solution
- Note: there will be compile error, just ignore
- Note: you can not find the new struct in UE Editor
- Note: this compile action will start UnrealHeaderTool that will generate *.generated.h
- Edit code,include *.generated.h
#include "CoreMinimal.h" #include "MyNewStruct.generated.h" USTRUCT(BlueprintType) struct FMyNewStruct { GENERATED_BODY() };
- Build Solution AGAIN!
- build will success
- and struct can be found in UE Editor
中文版
- 在工程目录添加一个.h文件
- 添加如下代码
#include "CoreMinimal.h" USTRUCT(BlueprintType) struct FMyNewStruct { GENERATED_BODY() };
- 注意:Struct必须以F开头
- 注意:GENERATED_BODY不能省去
- 生成项目
- 注意,此时会报错,不用关注
- 注意,此时在UE编辑器中仍旧找不到该新建Struct
- 此次编译的目的:触发一次UnrealHeaderTool,生成文件对应的.generated.h文件
- 修改代码,包含.generated.h
#include "CoreMinimal.h" #include "MyNewStruct.generated.h" USTRUCT(BlueprintType) struct FMyNewStruct { GENERATED_BODY() };
- 再次生成项目
- 此时可以成功编译
- 引擎中也能找到类型定义