Hi, I am working on loading levels from pak files. I successfully loaded widget assets, but I failed to load the level using a similar method. I placed them in the same directory, but I encountered issues:
LogLinker: Warning: Failed to load '/Game/Pak2/NewWorld': Can't find file.
Here is my code:
TSharedPtr<FPakPlatformFile> pakPlatformFile = MakeShareable(new FPakPlatformFile());
pakPlatformFile->Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT(""));
IPlatformFile& oldPlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPlatformFileManager::Get().SetPlatformFile(*pakPlatformFile);
if (WITH_EDITOR)
{
pakPlatformFile->Mount(TEXT("D:/code_study/Content/Paks/pakchunk2-Windows.pak"), 1, TEXT("D:/code_study/Content/Pak2/"));
GAllowUnversionedContentInEditor = true;
}
else
{
pakPlatformFile->Mount(TEXT("D:/code_study/Content/Paks/pakchunk2-Windows.pak"), 1, TEXT("../../../Content/Pak2/"));
FPlatformFileManager::Get().InitializeNewAsyncIO();
}
FString worldPath = TEXT("/Game/Pak2/NewWorld");
UGameplayStatics::OpenLevel(GetWorld(), FName(*worldPath));
FPlatformFileManager::Get().SetPlatformFile(oldPlatformFile);
BTW I am using UE 5.3. I wonder if there is any tutorial introducing how to load maps from pak files?