Hello,
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).
Requirements
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?