Is there a way to leverage UE4 c++ cgeneration

Hi, i’m use to do some code generation in other languages, and seeing UE4 has a full backend using code generation sound promising. But i haven’t seen any simple way to add my own code generation to UE4.

That would be wonderful to be able to use that system, after a look of internet, looks like nobody asked about that before.

I hope there is a way to do it without using full engine sources as it’s meant to work in a pluggin. but if there’s any other leads for it i would gladly have a look anyway :slight_smile:

Have a good day ! :slight_smile:

Up ? ( that something i’m really intrested to )

UnrealBuildTool manages building process (like "make) and UnrealHeaderTool is one reading headerfiles in serch of UPROPERTY, UFUNCTION etc and generation code based on it, you would need to modify UHT to add anything in it sadly. But you can add custom programs either in Build.bat or try add some code in build script (.cs files in source drectory, which are C#), 2nd option is less invasive as cs files are in your project code.

If you want to add functionality to UPROPERTY, UFUNCTION there way to do it in even easier way, there specifier called “meta” (i bet you already seen some examples of it) in which you can place any meta varables in it without limitations (atleast that i know) and UHT takes them add then to generated code and in runtime you can read them with GetMeta functions from UField in reflection system (this includes UClass* which is easiest to get, property searching requires use of TFieldIterator to find them)

thanks a lot for theses informations !

I know about UE reflection mechanism, but i think code gen is way cleaner for my need. but editing UHT might be not… i will have a look to see if i can make it mode modular and allow side code easily to UHT :slight_smile:

any document to share that would help dig in UHT ?