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

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.

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.

1 Like