Question:
Is it possible to edit the file templates used by Rider to create Unreal Engine entities?
Answer:
Yes, it is possible. In fact, the file templates used by engine are stored in the engine folder itself ( {ENGINE_ROOT}/Content/Editor/Templates/). The engine itself uses files there for file generation. Rider reads these .template files when opening a project. This means that after making changes to .template files in the engine, it is necessary to restart Rider for the changes to take effect.
How to:
Important note: There is a set of custom file templates stored in the engine. By file names, it is clear what kind of entity it corresponds to. But there is a specific one UObjectClass.cpp.template/ UObjectClass.h.template . It is being used for those rest classes for which a dedicated pair of .cpp files doesn't exist, e.g. AKillZVolume:
So that, editing UObjectClass.cpp.template/ UObjectClass.h.template will affect UObject + all those classes that are not listed in the Common tab when one creates an Unreal class:
For example, one might want to use the #include UE_INLINE_GENERATED_CPP_BY_NAME(%UNPREFIXED_CLASS_NAME%) feature (supported in UE 5.1 and greater). It reduces linking times and speeds up overall project build times.
Steps to make Rider (and UE) to use this definition in a .cpp file by default:
- Open the necessary template file under
{ENGINE_ROOT}/Content/Editor/Templates/, e.g.ActorClass.cpp.template; - Paste
#include UE_INLINE_GENERATED_CPP_BY_NAME(%UNPREFIXED_CLASS_NAME%)to a proper spot;- Note: UE templating engine has its own set of macroses. There is no documented list of these macroses, but mostly they can be seen in the
{Engine}/Source/Editor/GameProjectGeneration/Private/GameProjectUtils.cppfile;
- Note: UE templating engine has its own set of macroses. There is no documented list of these macroses, but mostly they can be seen in the
- Restart Rider;
Comments
0 comments
Please sign in to leave a comment.