Tutorial: Example Project: Loading Pak Files At Runtime

I suspect once the Pak is loaded you will just need to determine the path to the asset and use a soft reference to get it. I’d recommend you check out my colleagues post here.

Quote:
The AssetRegistry only knows about the assets that were present at cook time. It loads this cached information during startup from the serialized version of the AssetRegistry (AssetRegistry.bin) which is stored inside pak files.

Unreal will load a number of AssetRegistry.bin files during startup, for example the AssetRegistry for each plugin is loaded on startup, if it is present.

Additionally the AssetRegistry listens to the FPackageName::OnContentPathMounted delegate, so when a new mount point is mounted the Asset Registry will start to asynchronously search the new directories for any assets and add them to the internal database.

This will be asynchronous and the asset might not be available immediately.

IAssetRegistry::ScanPathsSynchronous can be used to force an immediate update of the asset cache and make new assets available through the asset registry in the same frame.

Hope that helps you take the next steps.

Edit:
Well there is no point on continuing on this topic.

I was following this idea of using the pak file as a mod loader and using AI to help with the registry stuff, then I found this page, got excited, then after messing with it and looking at the links above, this answer in particular (How to mount pak files without breaking the loading of other assets? - #3 by Chatouille) trying this is basically useless, as any link will get confused with the origing of the link in the pak file.

So, seems like the Plugin alternative is the only solution as any link would have a different start mount point. I didn’t test with the plugin alternative yet…

Well if anyone had success doing it, please mark me in the thread!


Was this running on 5.4 as you said?
I can’t compile it, as it complains about having the Records.Add(It)

'FPakFile::FFilenameIterator::FFilenameIterator(const FPakFile::FFilenameIterator &)': attempting to reference a deleted function,



GetPakContent(const FString& PakFilePath, bool bOnlyCooked /*= true*/) {
...

TArray<FPakFile::FFilenameIterator> Records;
for (FPakFile::FFilenameIterator It(*Pak, false); It; ++It) {
    Records.Add(It);
}

Well just move the code from the loop below inside the above loop, and problem solved.
Now that I’m looking at it, why would we do two loops instead of only 1?

		TArray<FPakFile::FFilenameIterator> Records;
		for (FPakFile::FFilenameIterator It(*Pak, false); It; ++It)
		{
			if (bOnlyCooked)
			{
				if (FPaths::GetExtension(It.Filename()) == TEXT("uasset"))
				{
					PakContent.Add(FString::Printf(TEXT("%s%s"), *PakAppendPath, *It.Filename()));
				}
			}
			else
			{
				PakContent.Add(FString::Printf(TEXT("%s%s"), *PakAppendPath, *It.Filename()));
			}
		}