x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

What is the correct path name for a level in a plugin pak loaded in runtime?

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.

Product Version: UE 4.18
Tags:
more ▼

asked May 30 '18 at 10:11 AM in C++ Programming

avatar image

XIXGAMES
81 6 7 12

avatar image Bariudol Aug 30 '18 at 12:02 PM

Did you ever find a solution to this?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question