Hello guys, I’m trying to understand how do I need to specify the path to async load assets from a pak in runtime, I’m using this plugin adapted to 4.18.3 and this is the function load the assets:
bool FAssetStreamer::StreamPackage(const FString& PakFileName, IAssetStreamerListener* AssetStreamerListener, EAssetStreamingMode::Type DesiredMode, const TCHAR* CmdLine)
{
Lock();
Listener = NULL;
const bool bRemote = (DesiredMode == EAssetStreamingMode::Remote);
if (!(bRemote && UseRemote(CmdLine) || !bRemote && UseLocal(CmdLine)))
{
Unlock();
return false;
}
CurrentMode = DesiredMode;
FPlatformFileManager::Get().SetPlatformFile(*PakPlatform);
// Now Get the path and start the streaming
const FString FilePath = bRemote ? ResolveRemotePath(PakFileName) : ResolveLocalPath(PakFileName);
if(!FPaths::FileExists(FilePath))
{
Unlock();
UE_LOG(LogAsyncPackageStreamer, Error, TEXT("Invalid pak file path: %s"), *FilePath);
return false;
}
// Make sure the Pak file is actually there
FPakFile PakFile(PakPlatform.Get(), *FilePath, bSigned);
if (!PakFile.IsValid())
{
Unlock();
UE_LOG(LogAsyncPackageStreamer, Error, TEXT("Invalid pak file: %s"), *FilePath);
return false;
}
PakFile.SetMountPoint(*FPaths::EngineContentDir());
const int32 PakOrder = 0;
if (!PakPlatform->Mount(*FilePath, PakOrder, *FPaths::EngineContentDir()))
{
Unlock();
UE_LOG(LogAsyncPackageStreamer, Error, TEXT("Failed to mount pak file: %s"), *FilePath);
return false;
}
// Load all assets contained in this Pak file
TSet<FString> FileList;
PakFile.FindFilesAtPath(FileList, *PakFile.GetMountPoint(), true, false, true);
// Discover assets within the PakFile
StreamedAssets.Empty();
for (TSet<FString>::TConstIterator FileItem(FileList); FileItem; ++FileItem)
{
FSoftObjectPath AssetName = *FileItem;
FString AssetNameString = AssetName.ToString();
if (AssetNameString.EndsWith(FPackageName::GetAssetPackageExtension()) ||
AssetNameString.EndsWith(FPackageName::GetMapPackageExtension()))
{
//AssetNameString = AssetNameString.Replace(L".umap", L".AdditionalLevel").Replace(L"../../../Engine/Content/Plugins", L"/Engine/Content/Plugins");
// TODO: Set path relative to mountpoint for remote streaming?
//StreamedAssets.Add(AssetName);
//{AssetPathName=0x0000024d0e423d30 "../../../Engine/Content/Plugins/MyDLC/Content/AdditionalLevel.umap" ...}
StreamedAssets.Add(
//AssetNameString.Replace(L"../../../Engine/Content/Plugins", L"???")
AssetNameString
);
//another method?
/*FStreamableManager AssetLoader;
FStringAssetReference AssetRef(AssetNameString); // .Replace(L"../../../Engine/Content/Plugins", L"/Engine/Content/Plugins"));
AssetLoader.LoadSynchronous(AssetRef);*/
}
}
// Once we started the async work assign listener
Listener = AssetStreamerListener;
// Tell the listener which assets we are about to stream
if (Listener)
{
Listener->OnPrepareAssetStreaming(StreamedAssets);
}
// IF we have not yet a StreamableManager setup (Arrr...) abort
if (StreamableManager == nullptr)
{
Unlock();
UE_LOG(LogAsyncPackageStreamer, Error, TEXT("No StreamableManager registered, did you missed to call initialize?"));
return false;
}
//StreamableManager->RequestAsyncLoad(StreamedAssets, FStreamableDelegate::CreateRaw(this, &FAssetStreamer::OnStreamingCompleteDelegate));
return true;
}
The problem is that the asset finding for the map is failing, I mean, when I tried to call the assetloader function to load synchronous an asset reference with the path given in the pak from the mounting point, it wont find the file and fail.
so what should i use here?
//AssetNameString.Replace(L"…/…/…/Engine/Content/Plugins", L"???")
Oh, for the pak i’m using a plugin with a level in the content dir called AdditionalLevel.