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!
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);
The unmount crash was fixed by calling:
mp_DLCPakFiles->InitializeNewAsyncIO();
Prior to:
FPlatformFileManager::Get().SetPlatformFile(*mp_DLCPakFiles);
Can ths be made as a C++ class for blueprnt users? Been lookng for a mountng system but cant fnd one.