# Manually trigger selective code generation

**URL:** <https://forums.unrealengine.com/t/manually-trigger-selective-code-generation/426857>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [June 7, 2018, 7:54am UTC](https://forums.unrealengine.com/t/manually-trigger-selective-code-generation/426857 "2018-06-07T07:54:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheAvatar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheAvatar](https://forums.unrealengine.com/u/TheAvatar)\
**Post date:** [June 7, 2018, 7:54am UTC](https://forums.unrealengine.com/t/manually-trigger-selective-code-generation/426857/1 "2018-06-07T07:54:34Z")

</div>

Hey there,

I have a plugin that imports custom assets from custom data.  
I also want to create a number of enums during the import that are then available in code.

I tried to achieve that through creating UUserDefinedEnum during import, but that did not make me happy. I would still need to access its enumerators through strings. I would like to avoid that.

So, I thought it might be possible to programmatically create a header (somewhere) with real enums in it on import and then trigger code generation and probably hot-reload manually.

Is that possible? How would I do that? Calling UnrealHeaderTool by myself? And with what parameters?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Shadowriver](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shadowriver](https://forums.unrealengine.com/u/Shadowriver)\
**Post date:** [June 7, 2018, 8:04am UTC](https://forums.unrealengine.com/t/manually-trigger-selective-code-generation/426857/2 "2018-06-07T08:04:51Z")

</div>

So i assume you want enum to be accessible in C++ for developer to use, since otherwise it’s pointless to make them, strings would be enough to deal with

Simply write header file in to source, here you have guide on reading and writing files

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

And you can get location path using those static functions:

> **[FPaths](https://docs.unrealengine.com/5.1/en-US/API/Runtime/Core/Misc/FPaths/)**
>
> Path helpers for retrieving game dir, engine dir, etc.

The only issue is you will need to read up modules names to put headers in, or potentialy add new module with enums and add module to uproject.

Note that this require UE4 user to have VS installed eitherway

---

<div class="post-metadata">

**Author:** ![TheAvatar](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheAvatar](https://forums.unrealengine.com/u/TheAvatar)\
**Post date:** [June 7, 2018, 8:16am UTC](https://forums.unrealengine.com/t/manually-trigger-selective-code-generation/426857/3 "2018-06-07T08:16:45Z")

</div>

Hey ,

you assume correctly.

If I would do that, I would “contaminate” my source files. Those enums defs would become part of version control. I don’t like that very much.  
I was thinking of doing something directly to Intermediate or DerivedDataCache, as I think that’s where constructs are put that come from code and are accessible in the editor.

Is there a way to do that? Am I thinking in the right direction … at all?
