Best practices for managing lots of assets

My general approach involves an asset manager that performs lazy loading and handles providing already lazy loaded assets. When an asset is requested directly it is loaded immediately but all other assets are loaded whenever there is some extra time remaining in the current frame. I try to defer requesting an asset until the last possible moment so it has a better chance of being preloaded when it won't potentially block the update loop.

So basically you would have a preload method for each of your types that takes a list of all assets of that type. At the end of every frame you run a lazy loading method to load assets if there's available time left in that frame. Finally you use a get method for each type at the last possible moment that will either return the already lazy loaded asset or load it directly (and cache it for future calls).

Here's an (untested) example Lua implementation of that idea: AssetManagement.zip (6.3 KB) (updated 2021-01-05)

9 Likes