When I #include “Runtime/PakFile/Public/IPlatformFilePak.h”,there are so many error from IPlatformFilePak,how to fix it?
I got error from FPakPlatformFile if I don’t include IPlatformFilePak.
or who has the full code about load asset from pak file ,thanks!!
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPakPlatformFile* PakPlatformFile= new PakPlatformFile();
PakPlatformFile->Initialize(&PlatformFile, TEXT(""));
FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
const FString PakFilename = FPaths::GameContentDir() + TEXT("Data/OutPak1.pak");
FPakFile PakFile(*PakFilename, false);
FString MountPoint(FPaths::EngineContentDir());
PakFile.SetMountPoint(MountPoint);
if (PakPlatformFile->Mount(*PakFilename, 0, *MountPoint))
{
UE_LOG(LogClass, Log, TEXT("MountSuccess"));
TArray<FString> FileList;
PakFile.FindFilesAtPath(FileList, *PakFile.GetMountPoint(), true, false, true);
FStreamableManager StreamableManager;
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,Log,TEXT("Can not Load asset..."))
}
}
else
{
UE_LOG(LogClass, Error, TEXT("Mount Failed"));
}