Hi,
I’m trying to add assets dynamically from the internet. First I create a .pak-file with a single sphere via command line and loading it from a local path. With the command line I tested and extracted the .pak-file. Everything seems to be good with this file. But i get problems with the StreamableManager. Can somebody help?
Here my steps of the following code:
- loading the .pak-file and mount it to my engine directory
- searching for the .uasset files and print names and count in console
- Loading the assets with a FStreamableManager.synchonousload()
Thats my OUTPUT:
LogTemp:Error: VALID pak file: C:/Users/Nils/Desktop/out.pak
LogTemp:Error: Number of assets = 1
LogTemp:Error: Find asset = ../../../Engine/Content/Sphere.uasset
**LogUObjectGlobals:Warning: Failed to find object 'Object None../../../Engine/Content/Sphere.uasset'
LogStreamableManager: Failed attempt to load ../../../Engine/Content/Sphere.uasset**
CODE:
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FPakPlatformFile* PakPlatform = new FPakPlatformFile();
PakPlatform->Initialize(&PlatformFile, TEXT(""));
FPlatformFileManager::Get().SetPlatformFile( *PakPlatform );
const FString PakFileName = TEXT("C:/Users/Nils/Desktop/out.pak");
FPakFile PakFile(*PakFileName, false);
if (!PakFile.IsValid())
UE_LOG(LogTemp, Error, TEXT("INVALID pak file: %s"), *PakFileName);
if (PakFile.IsValid())
UE_LOG(LogTemp, Error, TEXT("VALID pak file: %s"), *PakFileName);
PakFile.SetMountPoint(*FPaths::EngineContentDir());
const int32 PakOrder = 0;
if ( !PakPlatform->Mount(*PakFileName, PakOrder, *FPaths::EngineContentDir()))
UE_LOG(LogTemp, Error, TEXT("Failed to mount pak file: %s"), *PakFileName);
TSet<FString> FileList;
PakFile.FindFilesAtPath(FileList, *PakFile.GetMountPoint(), true, false, true);
UE_LOG(LogTemp, Error, TEXT("Number of assets = %ld"), FileList.Num());
StreamedAssets.Empty();
for (TSet<FString>::TConstIterator FileItem(FileList); FileItem; ++FileItem)
{
FString AssetName = *FileItem;
UE_LOG(LogTemp, Error, TEXT("Find asset = %s"), *AssetName);
if (AssetName.EndsWith(FPackageName::GetAssetPackageExtension()) || AssetName.EndsWith(FPackageName::GetMapPackageExtension()))
StreamedAssets.Add(AssetName);
}
UObject *object = Cast<UStaticMesh>( AssetLoader->SynchronousLoad(StreamedAssets[0]));