首先需要在**本项目**中cook内容,内容放在content文件夹下,cooked文件在[ProjectName]\Saved\Cooked\WindowsNoEditor\[ProjectName]\Content\[CookedFolder]
然后用引擎自带的unrealpak打包成一个pak文件 unrealpak D:\MyDesktop\Apple.pak -create=[ProjectName]\Saved\Cooked\WindowsNoEditor\[ProjectName]\Content\[CookedFolder] -compressed
最后在运行时加载:
void AMyActor::BeginPlay()
{
Super::BeginPlay();
OldPlatform = MakeShareable(&FPlatformFileManager::Get().GetPlatformFile());
PakPlatformFile = MakeShareable(new FPakPlatformFile());
PakPlatformFile->Initialize(OldPlatform.Get(), TEXT(""));
TestLoadPak(TEXT("D:\\MyDesktop\\Apple.pak"));
}
void AMyActor::TestLoadPak(FString InFullPath)
{
FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
FString PakFileFullPath = InFullPath;
FPakFile* TmpPak = new FPakFile(PakPlatform