I would like to find out if it is possible to register new dynamic enums into the UE Reflection System during runtime?
We have some game data outside the UE and we would like to be able to use it as UEnums in the game and editor after deserializing it. Is that possible? And if so, could you give me a code example of how to do it?
The reflection pass is done during compile time by the Unreal Header Tool which inspects files for the “include *.generated.h” include directive for inclusion into the reflection system. It then parses that file examining member annotations and expanding macros to create the final .gen and .generated.h files in Intermediate\Build\<Platform>\UnrealEditor\Inc\<ProjectName>\UHT .
These are then compiled into binaries for the Editor to utilize during the build step, prior to runtime.
You can link to external files and directories during build time by adding the file paths to the folders containing the .h and/or .cpp files to include.
PublicIncludePaths.AddRange( new string[] { "C:/Users/Me/Documents/ExternalProjectFiles/Public", System.IO.Path.Combine(ModuleDirectory, "../../../../../Documents/ExternalProjectFiles/Public") } );They would still have to contain the "include FileName.generated.h” line and be decorated with the appropriate member annotations to be added in the code reflection parse.
One option to resolve an enum during runtime could be to create some tooling that reads in a file of integer values to compare against known enum values.
If you can provide some more information on your use case I can attempt to find a more bespoke solution.