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"

How to mount a pak file at Game Content Directory?

For now, I can mount a pak file at Engine Content Directory and then load asset from it. (path is "/Engine/AssetName.AssetName")

When I change the mount point to Game Content Directory (FPaths::GameContentDir()), the mount method return success, but I just can not load asset.

The Error logs are something like:

 LogLinker:Warning: Can't find file '/Game/AssetName'
 LogLinker:Warning: Can't find file '/Game/AssetName'
 LogUObjectGlobals:Warning: Failed to find object 'Object /Game/AssetName.AssetName'

Can anybody tell me how to mount a pak file at Game Content Directory? Or is there a way to let the engine auto load and mount my pak file at start ? (I use UnrealPak.exe to generate pak file)

Any help will be appreciate!

Product Version: UE 4.14
Tags:
more ▼

asked Mar 11 '17 at 09:07 AM in C++ Programming

avatar image

Adcentury
32 3 5 11

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

2 answers: sort voted first

This is the code I'm using. Please note since 4.15 I'm having a crash on Un mount, but the mount is working still.

 bool DLCDownloadManager::MountPak(const FString &rPakFileName, DLCMountPointInfo &rMPI)
 {
      //Load and mount pak file
     if (mp_DLCPakFiles == nullptr)
     {
         mp_DLCPakFiles = new FPakPlatformFile;
         if (!mp_DLCPakFiles->Initialize(&FPlatformFileManager::Get().GetPlatformFile(), TEXT("")))
         {
               return false;
         }
 
         FPlatformFileManager::Get().SetPlatformFile(*mp_DLCPakFiles);
     }
 
     FString StandardFilename(rPakFileName);
     FPaths::MakeStandardFilename(StandardFilename);
     StandardFilename = FPaths::GetPath(StandardFilename);
     
     if (!mp_DLCPakFiles->Mount(*rPakFileName, 0, *StandardFilename))
     {
          return false;
     }
 
     static int siMountIndex = 0;
     rMPI.m_Directory = StandardFilename;
     rMPI.m_MountPoint = FString::Printf(_T("/DLC%d/"), siMountIndex++);
     FPackageName::RegisterMountPoint(rMPI.m_MountPoint, StandardFilename);
 
 #if 0 //Enable to dump files and directories while debugging
     struct Dump : public IPlatformFile::FDirectoryVisitor
     {
         virtual bool Visit(const TCHAR* FilenameOrDirectory, bool bIsDirectory)
         {
                 SysOutputf(DownloadManager, bIsDirectory ? _T("Directory: %s") : _T("File: %s"), FilenameOrDirectory);
             return true;
         }
     };
     Dump visitor;
     mp_DLCPakFiles->IterateDirectoryRecursively(*StandardFilename, visitor);
 #endif
 
     return true;
 }


The important bit for you is probably here:

 rMPI.m_MountPoint = FString::Printf(_T("/DLC%d/"), siMountIndex++);
 FPackageName::RegisterMountPoint(rMPI.m_MountPoint, StandardFilename);


more ▼

answered May 02 '17 at 03:57 PM

avatar image

theonecalledtom
1.1k 47 34 233

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

The unmount crash was fixed by calling:

 mp_DLCPakFiles->InitializeNewAsyncIO();

Prior to:

 FPlatformFileManager::Get().SetPlatformFile(*mp_DLCPakFiles);


more ▼

answered May 23 '17 at 11:29 PM

avatar image

theonecalledtom
1.1k 47 34 233

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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