Hi, how to load a level that is in .pak file?
I spend many hours researching and trying. There are many forum questions about this.
On recurring method I found is by using:
if (FCoreDelegates::MountPak.IsBound())
{
FString pakPath = TEXT("../../../MyProject/Content/somePack.pak");
IPakFile* pakFile = FCoreDelegates::MountPak.Execute(pakPath, 4);
if (pakFile)
{
const auto& mountPoint = pakFile->PakGetMountPoint();
UE_LOG(LogTemp, Warning, TEXT("LoadPakDelegate(): MountPoint %s"), *mountPoint);
FString pakContentPath = mountPoint + "MyProject1/Content/";
FPackageName::RegisterMountPoint("/Game/", pakContentPath);
UGameplayStatics::OpenLevel(world, FName(TEXT("Map2")));
}
}
else
{
UE_LOG(LogTemp, Warning, TEXT("LoadPakDelegate(): OnMountPak.IsBound() Falied"));
}
I could only find this in Chinese website, stating that FCoreDelegates::MountPak.IsBound() will always return false in editor. (Of course we need editor method as-well, for developing thigs)
I also found many mentions that “EXCLUDE_NONPAK_UE_EXTENSIONS has to be set to 0”, and custom built engine needs to be built with this flag. This did not work, as everyone also experienced.