Hey everyone, I am currently using a source built version of the engine and I create my .cpp/.h files manually outside of the editor because I don’t like the workflow of having to open the editor just to generate a new class. My question is though, how do I generate the boilerplate code that gets included in the #include “MyClass.generated.h”? I have all the code that the engine would generate for you except for that boilerplate code.
The generated file is, as its name indicates, generated by the build system. You don’t need to use the editor to add new files, you simply need to build your project and the generated files will be generated on demand.
The workflow is as follows:
- Create a new file according to the template below
- Right click on your project file and select “Generate Visual Studio project files” (if you are on windows)
- Open the solution and notice your file has been added
- Build the solution
- If there are no syntax errors the build system will generated the generated.h files for you and the build will succeed
A new file (SomeActor.h) should look like this:
#pragma once
#include "GameFramework/Actor.h"
#include "SomeActor.generated.h"
UCLASS(config = Game)
class USomeActor : public UActor
{
... your class here ...
};