hi guys.
i load a .pak file which import form .fbx , lost textures and Materials but if i drag to viewport is work fine. so can u get me some ideas?
the setup is:
- import the .fbx file ( import success)
- drag to viewport ( success)
3.make a pak file (success)
command is :
UnrealPak.exe F:\01.pak D:\PAKProject\Content\testFBX\1*
4.load pak to show (not work,lost textures and other)
my load code is :
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
PakPlatformFile->Initialize(&PlatformFile, TEXT(""));
FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
const FString PakFilename = TEXT("F:\\01.pak");
FPakFile PakFile(&PlatformFile,*PakFilename, false);
const FString MountPoint(FPaths::EngineContentDir());
PakFile.SetMountPoint(*MountPoint);
if (!PakPlatformFile->Mount(*PakFilename, 0, *MountPoint))
{
UE_LOG(LogClass, Warning, TEXT("Mount failed"));
return;
}
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;
for (auto f : FileList)
{
AssetShortName = FPackageName::GetShortName(f);
LeftStr;
RightStr;
AssetShortName.Split(TEXT("."), &LeftStr, &RightStr);
AssetName = TEXT("/Engine/") + LeftStr + TEXT(".") + LeftStr;
FStringAssetReference r = AssetName;
if (false == f.Equals(FileList[0]))
{
UObject* LoadObject = StreamableManager.LoadSynchronous(r, true);
}
}
UStaticMesh *LoadObject = Cast<UStaticMesh>(StreamableManager.LoadSynchronous(Reference, true));
if (LoadObject != nullptr)
{
UE_LOG(LogClass, Warning, TEXT("LoadPakFile Object load Success..."));
}
else
{
UE_LOG(LogClass, Warning, TEXT("LoadPakFile Can't load asset..."));
}
if (LoadObject != nullptr)
{
UE_LOG(LogTemp, Warning, TEXT("successs---------- "));
TestActor = GetWorld()->SpawnActor<AStaticMeshActor>(
AStaticMeshActor::StaticClass(),
FTransform(
FRotator::ZeroRotator, FVector(-600, 360, 170), FVector(1, 1, 1)
)
);
if (TestActor != NULL && !TestActor->IsPendingKill() && TestActor->IsValidLowLevel())
{
TestActor->GetStaticMeshComponent()->SetStaticMesh(LoadObject);
}
}
else {
GEngine->AddOnScreenDebugMessage(-1, 50.f, FColor::Red, TEXT("null"));
}