Why do I need this?
Unreal Engine's Asset System makes use of a file cache to load the bulk data for certain asset types. It stores this in the Derived Data Cache (DDC). If the editor cannot find cached data, or the cached data is out of date, it must generate it as the assets are loaded. This can take a huge amount of time and processing power. It is a very common (even usual) occurrence after syncing to the latest version in source control.
There's more information about how it all works on the Unreal Engine website.
This plugin makes use of the Automation Framework. (Further information on this can be found on the Unreal Engine website)
This performs the equivalent of you loading a level and pressing play. Because we are scheduling this to happen at a time the computer isn't being used, we get to do this 'for free'.
So what does it actually do?
The plugin contains a single automated test FillDDCForPIETest. It allows the user to predefine a list of maps they wish to cache data for, then for each map it will:
1. Open the map in Editor
- Wait for load to complete
- Wait for shaders to compile
2. Run Play In Editor (PIE)
- Wait for PIE to run
- Wait for load to complete
- Wait for shaders to compile
3. Run extra steps (These are defined in the configuration. See below.)
- Optional Wait for load to complete
- Optional Wait for shaders to compile
4. Close Play-In-Editor
- Wait for load to complete
- Wait for shaders to compile
Getting the plugin
The source code for the plugin, along with further information, can be found on our GitHub page.
Setting up the plugin
To Setup, you just add the maps you need to your UserEngine.ini or DefaultEngine.ini if you prefer like so:
[/Script/AutomateDDC.FillDDCForPIESettings]
Maps=/Game/Levels/SampleMap1
+Maps=/Game/Levels/SampleMap2
How to use the plugin
Create a batch file that runs something like this (put this at the end of your normal Sync script, or as a post sync/build step in Unreal Game Sync):
UE4Editor.exe "T:/Path/To/Your/Project/Game.uproject" -execcmds="Automation RunTests FillDDCForPIETest" -unattended
Additional (advanced) Uses
It is also possible to add additional steps to the automation. Each 'ExtraStep' executes a console command and then waits either for a time out, or for a specific message to appear in the log.
For example, once play in editor has opened a map, you may want to also activate the Pause Menu to cause all those assets to load and be pre-cached.
To do so, you could implement a console command to "OpenPauseMenu". This would open the game's menu and once completed, write 'Opened pause menu' to the log. Make a similar command to "ClosePauseMenu". To use these as part of the automation task, you would add the following to the config file:
[/Script/AutomateDDC.FillDDCForPIESettings]
Maps="/Game/Levels/SampleMap1"
+Maps="/Game/Levels/SampleMap2"
ExtraSteps=(StepId="Open Pause Menu",ExecCmd="openpausemenu",CompleteCondition=(LogStringForAdvance="Opened pause menu",TimeoutSeconds=600.0), bWaitForSettleAfterStep=True)
+ExtraSteps=(StepId="Close Pause Menu",ExecCmd="closepausemenu",CompleteCondition=(LogStringForAdvance="Closed pause menu",TimeoutSeconds=20.0), bWaitForSettleAfterStep=True)