# How to override and refresh loaded asset at runtime by mounting pak file manually?

**URL:** <https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134>\
**Category:** Programming & Scripting\
**Tags:** pak, unreal-engine, Packaging, question, CPP\
**Created:** [May 14, 2025, 1:23am UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134 "2025-05-14T01:23:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 1:23am UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/1 "2025-05-14T01:23:15Z")

</div>

## What is the goal

I am working on a demo of replacing textures by loading pak at runtime as a phased verification of a larger part of my work

The assets in the game are divided into two packages. The texture assets in the main pak package A.uasset are called the old version. The texture assets in the pack pak package A.uasset are called the new version. They are in the same path under the mount point and have the same name. I hope that the game does not need the pack pak file when it starts, but downloads the pack pak file later to replace the texture. So, I need to load the pak file manually and implement something to update the texture.

## What is the problem

After loading the backup pak during game runtime, the mount method returns true, indicating that the mount is successful. The priority is also set to 1000, and AssetRegistry.ScanPathsSynchronous is also called, but the texture is still not refreshed to the content in the backup pak

However, if the backup pak is renamed to \_P.pak before loading the game for the first time and placed in the directory where the main pak is located, that is, the two are at the same level, then according to the mechanism already written by UE, the backup pak can be loaded first. At this time, the image asset of the game when it is started is the content in the backup pak.

This also shows that there is no problem with my backup pak. It is simply a problem of loading method.

There are two possibilities

1. After the texture asset has been loaded, no matter how high the priority of the new pak file is when mounting, as long as the texture asset path is the same, the loaded asset will no longer be replaced.

2. Because the image resources have been loaded into memory, although the assets of the new pak have been loaded, this loading only updates the index structure and does not update the memory. Therefore, scanning the AssetRegistry is useless.

## What I have try

I have read UE docs about loading pak file:

[Primer: Loading Content and Pak Files at Runtime | Epic Developer Community](https://dev.epicgames.com/community/learning/knowledge-base/D7nL/unreal-engine-primer-loading-content-and-pak-files-at-runtime)

The docs lets me know about AsssetRegistry, but that is not enough.

I have read others’ question:

[How to load assets from a pak file at runtime? - Development / Rendering - Epic Developer Community Forums](https://forums.unrealengine.com/t/how-to-load-assets-from-a-pak-file-at-runtime/341713)

The question is about loading a new object that haved be instanced or loaded. But my question is how to load newer version asset from new pak, to replace older version of asset. The two version of asset have same path and same name.

## How do I debugging

Package the game as I say, call UnrealPAK to gain my desired main.pak and pack.pak

Replace original pak file by my main.pak, then start packaged game.

When game is running, I call my custom pak loading function. Parameters are: `PakFilename` is the absolute path of pack.pak, `PakOrder` is 1000, `MountPoint` is `\Game\`. My desired asset to replace is definitely in `/Game/`, because I have checked in editor.

> Edit: `\Game\` is error

Now I wish the texture I loaded is overrided and refreshed, but it didn’t.

## My coding

```cpp
#include "PakBlueprintLibrary.h"

#include "IPlatformFilePak.h"
#include "AssetRegistry/AssetRegistryModule.h"

bool UPakBlueprintLibrary::LoadPakFile(const FString& PakFilename, int PakOrder, const FString& MountPoint)
{
	IPlatformFile& InnerPlatform = FPlatformFileManager::Get().GetPlatformFile();
	FPakPlatformFile* PakPlatformFile = new FPakPlatformFile();
	PakPlatformFile->Initialize(&InnerPlatform, TEXT(""));
	FPlatformFileManager::Get().SetPlatformFile(*PakPlatformFile);
	
	FPakFile* Pak = new FPakFile(&InnerPlatform, *PakFilename, false);
	if (!Pak->IsValid())
	{
		return false;
	}

	if(!PakPlatformFile->Mount(*PakFilename, PakOrder, *MountPoint))
	{
		return false;
	}

	FAssetRegistryModule& AssetRegistryModule = FModuleManager::LoadModuleChecked<FAssetRegistryModule>(TEXT("AssetRegistry"));
	IAssetRegistry& AssetRegistry = AssetRegistryModule.Get();
	AssetRegistry.ScanPathsSynchronous({MountPoint}, true);

	return true;
}

```

## Platform

OS: Windows11

UE: 4.27.2

Anyone knows some information? Or some guidance about which part of UE source code should I investiagte? Thanks!

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 6:51am UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/2 "2025-05-14T06:51:51Z")

</div>

Another problem appear: I try to load blueprint after mounting pack pak file and fail.

My loading process can run in PIE mode, can run in packaged mode when having main pak and pack pak together. Error only happens when I launch game with main pak only and try to mount pack pak file.

It shows that the problem of texture doesn’t refresh is hidden. Now the biggest problem is, why I can’t load blueprint when pak is mounted successfully.

My loading blueprint code is

```cpp
bool UPakBlueprintLibrary::SpawnActorFromBPPath(const FString& BPPath, UObject* WorldContextObject, AActor*& OutActor)
{
	OutActor = nullptr;

	if (!WorldContextObject)
	{
		UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: WorldContextObject is null"));
		return false;
	}

	UWorld* World = WorldContextObject->GetWorld();
	if (!World)
	{
		UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Cannot get UWorld from WorldContextObject"));
		return false;
	}

	// Load the Blueprint class
	UClass* BPClass = LoadObject<UClass>(nullptr, *BPPath);
	if (!BPClass)
	{
		UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Failed to load BP class at path: %s"), *BPPath);
		return false;
	}

	// Spawn parameters
	FActorSpawnParameters SpawnParams;
	SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
	
	AActor* NewActor = World->SpawnActor<AActor>(BPClass, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams);
	if (!NewActor)
	{
		UE_LOG(LogTemp, Warning, TEXT("SpawnActorFromBPPath: Failed to spawn actor from BP class"));
		return false;
	}

	OutActor = NewActor;
	return true;
}

```

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 2:08pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/3 "2025-05-14T14:08:47Z")

</div>

Fine, the problem is my mount point parameter is error.  
My pack pak file has same folder structure of main pak.  
And main pak is mounted when game initialize.  
I add break point when game initialize and then see `FPakPlatformFile::MountAllPakFiles` is loading the initial pak.  
And `FPakPlatformFile::MountAllPakFiles` use empty mount point.  
So I follow the same empty mount point to mount my pack pak, then I can load blueprint class from pack pak successfully.

**But the question of replacing loaded asset is still here.**

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 14, 2025, 3:23pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/4 "2025-05-14T15:23:04Z")

</div>

> [@CheapMeow](#):
>
> Because the image resources have been loaded into memory, although the assets of the new pak have been loaded, this loading only updates the index structure and does not update the memory. Therefore, scanning the AssetRegistry is useless.

Essentially this.  
Assets (packages) are loaded from disk (=PAK) into memory, and stay in memory until unloaded. Adding a PAK with higher priority will only override assets that need to be loaded from disk AFTER mounting the new pak. On startup, all available paks are mounted at once, before loading assets, so when assets are loaded they are automagically retrieved from the higher priority pak.  
For what you want to do, it seems you’d have to manually patch everything on the fly, which I’m not sure is even possible for static level actors/geometry. Better course of action might be to write a solid savegame system, reload the level, and restore state.

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 3:39pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/5 "2025-05-14T15:39:54Z")

</div>

Thanks!  
However, what I want is that the level does not reload, only individual assets, is this possible?  
Theoretically, an object has a loading process when the game starts, which must have some function calls. If I call these functions to load objects again at runtime and require reading from the updated pak file system this time, can I update resources at runtime?  
I am still looking at the UE source code, but I am worried that I can’t find such a loading function.

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 3:46pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/6 "2025-05-14T15:46:18Z")

</div>

> [@Chatouille](#):
>
> For what you want to do, it seems you’d have to manually patch everything on the fly, which I’m not sure is even possible for static level actors/geometry

Temporarily, I only wish to replace texture at runtime. It looks simple because it will not be modified by runtime gameplay logic.

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 14, 2025, 4:19pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/7 "2025-05-14T16:19:18Z")

</div>

> [@CheapMeow](#):
>
> Theoretically, an object has a loading process when the game starts, which must have some function calls. If I call these functions to load objects again at runtime and require reading from the updated pak file system this time, can I update resources at runtime?

Static level objects are deserialized from the level (umap), so reloading them is essentially reloading the level. Dynamic objects are spawned by gameplay code and yes, you could replace them by destroying and respawning them. However you will lose all runtime state/changes.

> [@CheapMeow](#):
>
> Temporarily, I only wish to replace texture at runtime. It looks simple because it will not be modified by runtime gameplay logic.

In that case yes it may be possible to work out a simpler system. Look into function `LoadReplacementPackage` from PackageReload.cpp, it is not exported but it has a whole lot of interesting logic in it. Renaming the old package and triggering a load (StaticLoadObject or such) of the old path should make it load from disk again (fetching from new pak). Then it’s a matter of iterating all textureable objects (UMeshComponent subclasses for the most part) and re-assigning their materials.

Maybe you can simply use function `ReloadPackages` from PackageReload.h which is exported. If you are in luck, it could just do all the job for you. I haven’t dug that far in to see what it does exactly, but would be interesting to know the results.

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 14, 2025, 4:36pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/8 "2025-05-14T16:36:45Z")

</div>

> [@Chatouille](#):
>
> `ReloadPackages`

A direction is valuable, thank you!

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 15, 2025, 2:12pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/9 "2025-05-15T14:12:59Z")

</div>

I accomplish my goal with `ReloadPackages`. Thank you so much!

---

<div class="post-metadata">

**Author:** ![Chatouille](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chatouille/32/1194622_2.png) [@Chatouille](https://forums.unrealengine.com/u/Chatouille)\
**Post date:** [May 15, 2025, 2:17pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/10 "2025-05-15T14:17:26Z")

</div>

Nice!  
I’m curious, does it just do all the replacements automatically for you ? If so, that’s huge

---

<div class="post-metadata">

**Author:** ![CheapMeow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cheapmeow/32/1009431_2.png) [@CheapMeow](https://forums.unrealengine.com/u/CheapMeow)\
**Post date:** [May 15, 2025, 2:27pm UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/11 "2025-05-15T14:27:16Z")

</div>

Yes, it “do all the replacements automatically”.  
More clearly, it iterates all UObjects and replace old package reference with new package reference, meanwhile, deserialize the new data from new package to UObject.  
It maybe huge, but the performance analyzation is late work 😛

---

<div class="post-metadata">

**Author:** ![ShadowBr0kerz](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shadowbr0kerz/32/1201558_2.png) [@ShadowBr0kerz](https://forums.unrealengine.com/u/ShadowBr0kerz)\
**Post date:** [September 26, 2026, 9:11am UTC](https://forums.unrealengine.com/t/how-to-override-and-refresh-loaded-asset-at-runtime-by-mounting-pak-file-manually/2509134/12 "2026-09-26T09:11:13Z")

</div>

the pak mount path works but is the heavyweight option. for a demo of replacing textures at runtime there is a lighter pattern that avoids mount points and redirectors entirely:

loose file override: keep a folder next to the packaged build (or user content dir) with png files named to match your logical texture names. at runtime, load them with FImageUtils::ImportFileAsTexture2D, find the target material or texture parameter, and swap with create material instance dynamic plus set texture parameter value, or set texture 2d parameter on the component directly. no pak parsing, no object redirector walking, works in editor and packaged the same.

watching for changes: FDirectoryWatcher (editor and runtime on desktop platforms) fires a delegate when files in that folder change, so the reload becomes automatic: file edited in the art tool, saved into the watched folder, delegate fires, texture reimported, material parameter updated. that is a hot reload loop that survives packaging, and it is what makes the demo feel alive without manual buttons.

where the pak path genuinely wins, keep it: content that must behave as assets (referenced by other assets, surviving serialization, consoles with strict filesystems). for dev iteration and user-supplied textures on pc, loose files with a watcher are far less machinery.

one performance note: import the new texture async and swap the parameter only when the import completes, so there is no hitch while the file reads. and set the texture flags appropriately (no mips for UI previews, sRGB on for color textures) or the swap will look wrong in subtle ways.
