Hi, Im trying to get a Blueprint file from a .pak file. First I mount the .pak file and it seems to be working good, but I cant use the blueprint object that is inside. Im dying into it since days, can someone tell me whats wrong with this code?
void AMyFirstActor::Mount()
{
FString PakFileFullPath = TEXT("D:/UnrealEngine/Epic Games/Unreal Projects/MyProject01/WindowsNoEditor/MyProject01/Content/Paks/pakchunk1001-WindowsNoEditor.pak");
OldPlatform = &FPlatformFileManager::Get().GetPlatformFile();
if (!PakPlatform)//Judge whether the smart pointer is valid
{
PakPlatform = MakeShareable<FPakPlatformFile>(new FPakPlatformFile());
}
PakPlatform->Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT(""));
FPlatformFileManager::Get().SetPlatformFile(*PakPlatform.Get());
if(FPlatformFileManager::Get().GetPlatformFile().FileExists(*PakFileFullPath))//Determine whether the file exists
{
//Gets a reference to the pak file from the file system
FPakFile * TmpPak = new FPakFile(PakPlatform.Get(), *PakFileFullPath, false);
if (TmpPak)
{
TArray<FString> ExistPaks;
PakPlatform->GetMountedPakFilenames(ExistPaks);
if (ExistPaks.Find("pakchunk1001-WindowsNoEditor.pak") >= 0)
{
return;
}
FString PakMountPoint = TmpPak->GetMountPoint();
int32 Pos = PakMountPoint.Find("Content/");
FString NewMountPoint = PakMountPoint.RightChop(Pos);
NewMountPoint = FPaths::ProjectDir() + NewMountPoint;
TmpPak->SetMountPoint(*NewMountPoint);
if (PakPlatform->Mount(*PakFileFullPath, 1, *NewMountPoint))
{
//The uclass is null
UClass* uclass = LoadClass<AActor>(NULL, TEXT("Blueprint'Games/Blueprints/Blueprint_CeilingLight'"));
if (uclass)
{
AActor* actor = GetWorld()->SpawnActor<AActor>(uclass, FVector(0), FRotator(0));
}
}
}
}
FPlatformFileManager::Get().SetPlatformFile(*OldPlatform);
}