SideCode
SideCode

Reputation: 63

<Gameplay Class>.h vs <Gameplay Class>.generated.h

In unreal engine, what is the difference between the two? I could not find it in the API, just this: https://docs.unrealengine.com/5.0/en-US/gameplay-classes-in-unreal-engine/

I suspect that it adds .generated if you create the class from the Unreal editor, but I do not understand if it is any different with or without it.

Upvotes: 0

Views: 1197

Answers (2)

Max Play
Max Play

Reputation: 4037

Unreal has a code generation tool called "Unreal Header Tool" or UHT for short. During the build process of the project, it runs right before the actual compiler to generate code for the reflection, based on the UPROPERTY(), UFUNCTION(), USTRUCT(), UENUM(), etc. macros that you have in your code.

All that information is stored in two files: <Class>.generated.h and <Class>.generated.cpp

The header needs to be included last in the header to ensure that all references in a file are potentially valid in the generated code. Everything within the generated header file can be accessed via the UClass reflection system.

You can find the generated files in the "Intermediate/Build" directory of your project.

You can find the implementation of the UHT in the project on GitHub and a little more info about it in the docs.

Upvotes: 0

SideCode
SideCode

Reputation: 63

Ah, so the .generated header is required inside the actual header file of the class (specifically as the last header).

https://forums.unrealengine.com/t/creating-classes-in-visual-studio/282386/4

Upvotes: 0

Related Questions