Copy&Paste
void AAssetLoad::LoadPakFile()
{
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
PakPlatformFile->Initialize(&PlatformFile, TEXT(""));
FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
const FString PakFilename = FPaths::GameContentDir() + TEXT("Data/OutPak1.pak");
FPakFile PakFile(*PakFilename, false);
const FString MountPoint(FPaths::EngineContentDir());
PakFile.SetMountPoint(*MountPoint);
if (PakPlatformFile->Mount(*PakFilename, 0, *MountPoint))
{
UE_LOG(LogClass, Log, TEXT("Mount Success"));
TArray<FString> FileList;
PakFile.FindFilesAtPath(FileList, *PakFile.GetMountPoint(), true, false, true);
FStreamableManager StreamableManager;
// Static load object
FString AssetName = FileList[0];
FString AssetShortName = FPackageName::GetShortName(AssetName);
FString LeftStr;
FString RightStr;
AssetShortName.Split(TEXT("."), &LeftStr, &RightStr);
AssetName = TEXT("/Engine/") + LeftStr + TEXT(".") + LeftStr;
FStringAssetReference Reference = AssetName;
UObject* LoadObject = StreamableManager.SynchronousLoad(Reference);
if (LoadObject != nullptr)
{
UE_LOG(LogClass, Log, TEXT("Object load Success..."));
}
else
{
UE_LOG(LogClass, Error, TEXT("Can't load asset..."));
}
}
else
{
UE_LOG(LogClass, Error, TEXT("Mount failed"));
}
}