Adding new .h/.cpp files to engine source


I just cloned the UE 4 repository from GitHub and built it.

I added a pair of new .h and .cpp (for a new ParticleModule subclass). But when I tried to incrementally build the project again, the two files were not included in the building process. git status does not report their untracked status either.

How can I integrate the files into the engine build process? Thank you very much!

Which version are you using?

If you’re using the master branch, then you’ll need to re-generate projects before the build process picks up newly added source files (this is a change made post-4.7 to speed up the incremental build process at the cost of having to generate projects after performing certain actions).

No, that’s correct.

The VS Add Class wizard puts files in the temporary and out-of-source folder that we create when generating our project files. This folder doesn’t get scanned when looking for source code, but you’ve managed to move them to the correct place, so that’s fine :slight_smile:

Out of curiosity, do you need to add new code directly to the engine, or are you able to extend it via a separate custom runtime module instead (eg, your game module)?

Hi Jamie, I’m using 4.7 on master branch. One thing I notice is that if I add new .h/.cpp files by doing Add → New Item in VS’s Solution Explore, they will be created in Engine\Intermidiate\ProjectFiles, which are ignored by Git according to .gitignore. Re-running GenerateProjectFiles.bat does not seem to pick up those new files. By manually moving them into appropriate Engine\Source subdirectories, they will be compiled during the build. But still, I suspect that I have missed something here?

Thanks for the answer! I’m trying to add a customized particle module to render scanned point cloud data from files. But UParticleModule and its subclasses are not exported with ENGINE_API, which gave me linking errors when I tried to extend the functionality I need in a game module. Is there an alternative way to extend particle modules programmatically?

Ah, that’s unfortunate.

The classes themselves are publicly available outside their module, however they’re marked MinimalAPI which makes them incompatible with ENGINE_API at the class level. We’ve exported some of their functions, but not fully exported the type, so you get linker errors trying to derive from them :frowning:

I’m trying to find out whether you’re supposed to be able to derive from those outside of their module. If you are, then we’ll likely need to tweak their API exposure to allow it.

I’ll get back to you once I have more details, but it seems that adding them directly into the engine is the way to go for now.

Thank you, Jamie! Looking forward to it.

I am also curious what is the best/recommended way of doing this. Is it “unsupported” to add new particle modules via C++?

I’m happy to make changes to the engine code temporarily but I would certainly prefer to not have to use a modified version of the engine in the long run.