Packaging non-asset directories into their own chunk?

Funnily enough, that was my exact question and I came here for answers, and I found one! Just a quick remark before going into the details:

Packaging API files into .pak files is not always a good idea. I don’t know about wwise, but with fmod at least there’s a big warning to not do that, although it is supported. The issue is file/read locks while accessing the files in the .pak. It’s always good to test things out before shipping, but that should be obvious, I believe.

The answer to your question is as follows, in addition to +DirectoriesToAlwaysStageAsUFS:

You can use the DefaultPakFileRules.ini config file to specify the chunk for the files. Your file can look like this:

[MyMovieFiles]
OverridePaks="pakchunk1"
bOnlyChunkedBuilds=true
+Files=".../*.mp4"

See also Engine/Config/BasePakFileRules.ini for the few lines of documentation that exists there. There are plenty of other possibilities with that.

However, one other remaining point is very important when doing that: You can only package those files into a .pak file that “already exists”. This means, you can’t just specify "pakchunk5" and then the file will be generated, you have to make sure that – by normal packaging routines – the pakchunk5 exists. You can do that by making sure that one asset is packaged into that chunk, for example by adding a PrimaryAssetLabel data asset that’s a runtime label and assigned to chunk 5. Using the Asset Audit you can see which chunks exist.

I assume that you can theoretically pack your files in any custom-named chunk you want, but you somehow need to make sure that the chunk will actually be built. This is true for all chunks that exist via asset management (aka “pakchunkN” chunks).

Important also: I tried figuring this out by myself since there’s almost no documentation about it. Most documentation I found was the file BasePakFileRules.ini file mentioned above, as well as Engine/Source/Programs/AutomationTool/Scripts/CopyBuildToStagingDirectory.Automation.cs. I might be very wrong in certain parts and there might be other solutions to pack non-asset files in your custom chunk.

2 Likes