[Plugin] How to use header files cross module?

I have two modules. One of Runtime and one of Editor. I am structuring my plugin and modules exactly like Paper2D. Basically using that as my reference on everything as I move forward.

I have created a couple new assets, and I am trying to make the Factory classes for those assets. In Paper2D the actual assets are in the Runtime module, but the Factory classes are in the Editor module. The Factory classes in the Editor module are including the header files from the asset that exists in the Runtime module. So essentially the header is being used “cross module”. At first I wondered how this could be, then I noticed that in the Paper2DEditor PCH, there is an include for “Paper2DClasses.h” which when I look at it inidicates it is auto generated by UBT and it appears to allow Paper2DEditor, the Editor module, to use the headers defined in the Runtime module. Perfect.

When I try to do the same, my results are not so good. I ran into two problems that I am unsure how to fix.

  1. The compiler is complaining that the file, in my case HexedClasses.h, does not exist. Yet it does. I can right click on the include in VS and jump to it. It does exist but…
  2. While the file does exist and does seem to be generated by UBT, it is empty other than some boilerplate comments saying it is autogenerated.

So I guess my problem is two fold. First, what do I need to do so that UBT populates the ModuleClasses.h file properly, and second, why isn’t it being seen during compilation of the PCH despite the file being present?



1>------ Skipped Build: Project: UE4, Configuration: BuiltWithUnrealBuildTool Win32 ------
1>Project not selected to build for this solution configuration 
2>------ Build started: Project: BoardDev, Configuration: Development_Editor x64 ------
2>  Performing 5 actions (4 in parallel)
2>  PCH.HexedEditorPrivatePCH.h.cpp
2>G:\Documents\Dropbox\Development\BoardDev\Plugins\Hexed\Source\HexedEditor\Private\HexedEditorPrivatePCH.h(5): fatal error C1083: Cannot open include file: 'HexedClasses.h': No such file or directory
2>  -------- End Detailed Actions Stats -----------------------------------------------------------
2>ERROR : UBT error : Failed to produce item: G:\Documents\Dropbox\Development\BoardDev\Plugins\Hexed\Binaries\Win64\UE4Editor-HexedEditor.pdb
2>  Total build time: 22.43 seconds
2>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.MakeFile.Targets(38,5): error MSB3073: The command ""E:\Program Files\Epic Games\4.9\Engine\Build\BatchFiles\Build.bat" BoardDevEditor Win64 Development "G:\Documents\Dropbox\Development\BoardDev\BoardDev.uproject" -rocket" exited with code -1.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ==========


So the answer, for anyone else in the future who runs into this same issue, is actually rather obvious in hindsight. You just need to add the Runtime module as a dependency of your Editor module in the Editor module’s build script.

Now into the painful world of figuring out Actor Factories. UE4’s documentation falls off the face of the planet when you start digging into this stuff :frowning: