How to store LOTS of game assets to QUICKLY find and load in runtime


Short Desc

I’m working on a medium to large scale RTS style game in which i will need to store dozens if not hundreds of meshes, textures, sprites etc (units, weapons, icons, skills, items etc).


Say I want to store a list of units, each has some atributes (hp, atk, etc) and models/textures, sprites. If Im looking for a specific unit, the system needs to quickly find and retrieve it. But i’ll also need to load all of them to do some filtering or whatever. Kind of like a database, but stored locally in unity.

My Implementation so far / Ideas to improve existing solution

Currently, i have a Scriptable Object that stores all the unit’s stats, reference to the prefab with meshes/textures, sprites in a Resources folder. Each unit has a unique ID , then if i want to load a specific unit by ID, i first need to load ALL my units, check their IDs, then return the one with the correct ID. Problem is, buy doing this, the game has to load ALL the models, textures etc associated with all the units, which is less than ideal.

My idea for improving this would be to only store lightweight data (ids, names, descriptions, stats) in a ScriptableObject, so when looking through all my units, i only have to load some ints, strings…maybe an icon. But also store a string containing the location of the heavy data (meshes, textures) also in the Resources, but separately. This way, i can also load the actual prefab when i find the correct unit in the list.

This would probably work fine, but i imagine it seems rather messy and inelegant. There has to be a better way of doing this… How do huge RPGs or MMOs do it? Any suggestions?

Well, you could store each unit’s (or whatever else’s) data as an individual scriptable object (in separate folders to keep it clean) and then have a scriptable object with a dictionary and pass in the id and have it return the path to the data you’re requesting. I’m not sure if you have a resource database or if you have a database for each type of resource, but that would allow you to only search through a very lightweight dicitionary. If you want to further your question, I can try to think of something else, but this is what I would recommend.

The dictionary of course would have the key be whatever type you’re using for the ID and the value be a string for the path.