Loading Map from Pak at Runtime

What if FCoreDelegates::OnMountPak.IsBound() returns false? I’m trying with PIE, standalone and packaged versions, and always it returns false…

@mfish I know it’s been a few years but I’m trying to do this exact same thing. Whenever I mount a pak file with OnMountPak.Execute() and I try to use UGameplayStatics::OpenLevel() it tells me it can’t resolve the map file. Did you experience this? How did you fix it? Ive been struggling with this for weeks now.

Sure, I’ve gone mad to solve this problem and, finally, I solved by “just” modifying a single character of the engine source code and recompiling it.
In the file \Engine\Source\Runtime\PakFile\Private\IPlatformFilePak.cpp you have to modify the row
#define EXCLUDE_NONPAK_UE_EXTENSIONS 1
and change that 1 to 0

So compile the engine (a custom engine, not the Epic’s one) and try again. It requires some hours to download and compile the engine, but it’s worth it. You may have other problems in the future which require an engine edit.

You changed that one thing and you were able to load a map after mounting a pakfile with OnMountPak.Execute()?

Yes. This is my code:

bool ULevelsFunctionLibrary::MountPak(FString PakPath) {

if (FCoreDelegates::OnMountPak.IsBound()) {

return FCoreDelegates::OnMountPak.Execute(PakPath, 0, NULL);

}

return false;

}

before of that changing, the if check failed (and the Execute method too, if I called it in spite of the failed check). After that changing, the pak file is correctly mounted and I’m able to load the pak’s maps.

Okay, I’m going to try that now. Your code overall was basically this?

bool ULevelsFunctionLibrary::MountPak(FString PakPath) {
    if (FCoreDelegates::OnMountPak.IsBound()) {
        if (FCoreDelegates::OnMountPak.Execute(PakPath, 0, NULL))
        {
              UGameplayStatics::OpenLevel(GetWorld(), "map");
              return true;
        }
    }
    return false;
}

this didnt work, when I got to OpenLevel it still gave me failed to resolve map.umap.

1 Like