DLC system with .pak files. Mounting .pak files

Houston we have a problem!

I’m working on downloadable content system for my game project. I’m creating .pak files with cooked .uassets and .umaps using UnrealPak.exe. Mounting .pak files works fine, but when i try to load any object from this file like that:

ULevel* obj = Cast<ULevel>(StaticLoadObject(ULevel::StaticClass(), nullptr, TEXT("/Engine/pyramid_torus_map.umap")));

i get this error:

LogLinker:Warning: Unable to load package (../../../Engine/Content/pyramid_torus_map.umap). Package contains EditorOnly data which is not supported by the current build or vice versa.

It’s kinda dead end for me. Any tips on what might i be doing wrong?

I think you need to cook your package, but I am not sure how to do that without putting it with your other game content and cooking the whole thing.

My assets are all cooked before putting them in .pak file. I m not sure if it is possible to cook finished .pak.

I’m still stuck on reading assets from paks. Divine intervention is needed :slight_smile:

Ok this is solved. This error happens, when you try to load cooked assets in editor, or try to load not-cooked assets in released game. Kinda obvious but still…

Hi, I am trying to do something similar to this, but I’m having a lot of trouble.

Could you share how you were able to create a pak file and mount it?

Thanks!

First i m cooking all my assets with command line. You can use FMonitoredProcess class to call command line from code. Then i call UnrealPak.exe using the same class to create pak file. To mount pak files you can use this code:

IPlatformFile& InnerPlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
PakPlatformFile->Initialize(&InnerPlatformFile, TEXT(""));

bResult = PakPlatformFile->Mount(*PakFileName, PakOrder, *MountPoint);

The most not obvious thing about this process are paths to files. Files need to be mounted in engine dir. Game dir just doesnt work - i have no idea why. Also remember that assets are referenced with relative paths, so you need to keep the same catalog structure.

If you have more specific questions feel free to ask. Good luck.

Hi, I’m trying to create pak files recently, but now I’m stuck. Would you mind sharing more details in the pak file creating part? thx a lot.

I’ve been doing the following from the command line:

Engine/Binaries/Win64/UnrealPak.exe [path to the directory you want the pak in] -create=[path to a text file that lists the paths to the .uassets you want in the pak]

You can also make them from the editor by following the steps in this post:
http://www.tomlooman./add-mod-support-to-your-unreal-engine-4-game/

I’ve been doing the following from the command line:

Engine/Binaries/Win64/UnrealPak.exe [path to the directory you want the pak in] -create=[path to a text file that lists the paths to the .uassets you want in the pak]

You can also make them from the editor by following the steps in this post:
http://www.tomlooman./add-mod-support-to-your-unreal-engine-4-game/

Ok, I will have a try and thank you very much. :slight_smile:

Hello!From the UnrealEngine community,How to dynamically load the specified content in the PAK (as in a blueprint, material, and the name of the image from the PAK).Can you give me a demo code?My email address is comThanks to you!

http://pan.baidu./s/1o7T8LnG

http://pan.baidu./s/1o7T8LnG

I’m stuck on how to load and unload pak files, is it possible in blueprints?

ok so for mounting file, lets say my pak is in /Game/, what would be the relative path?