Trying to Learn Slate...

There’s a two things you can tweak for fast iteration with Slate.

The first is the precompiled header file. The default PCH file (i.e.: the SomeGame.h header you have to include in every cpp file) comes with the classes header in it:


#include "SomeGameClasses.h"

This includes all UObject classes in the PCH. If you’re modifying UObject headers, this means a full recompile whenever you touch it. On the other hand, Slate is native code, not UObject, so having all classes precompiled can save you some compile time. But if you’re touching UObjects while working on your UI, you’re better off disabling it.

The second thing is unity builds, which lump all CPP files into larger CPP files, resulting in less compile units and less overhead. This is great if you’re recompiling the entire project, but not so great if you only want to modify one Slate CPP file. The Unreal build tool tries to limit unity builds when few CPP files are involved but the cutoff is very low. However, you can control it in your build.cs (SomeGame.Build.cs) through the bFasterWithoutUnity option:


bFasterWithoutUnity = true;

This will force the build tool to compile all files individually, which is slower for a full rebuild but much faster for small iterations afterwards.

These two settings, when coupled with hot reload, can pretty much reduce your turnaround time to mere seconds. So when iterating in Slate only, I turn on the Classes PCH, turn off Unity build, and use the Compile button in the editor. Note that the first compile done this way requires a full rebuild due to the considerably different nature of hot reload game modules. But once that initial rebuild is done, subsequent recompiles will be very fast.