I’m working on building a squad based game, and want to build a roster with no set limit on its size. How should I store this data so I don’t get Sierra syndrome and end up hitting a point where I need to undo a whole lot of work? Should I store each squadmember as a gameobject which holds all the stats, then assign that gameobject to part of an array? Or is there a smarter, simpler way to store this information? I’d like to be able to easily refer to this info to display the character on a scrolling roster, and to call upon it in a mission scene, and of course be able to save it to a folder. I’m well aware of how to save to a folder, but I’m not sure about saving specific values of an array.
I don’t want to spend a ton of time working a system that will just end up not working, you know?
At the lowest level, the fastest way to leverage the Unity editor and internal structures is to use first class Unity objects like ScriptableObject to hold your data. That way you have a built in editor mechanism: the Unity editor!
It is still necessary to spend some time thinking about your problem space however. Data driven design!!
Is the roster fixed? Make a bunch of ScriptableObject instances, stick 'em in a folder, call it a day.
Is the roster generated at run time? Then you need to figure out how to make these things, what can change, etc.
Is the roster user-editable? Now you need a run-time editor too.
Is the roster extendable by a post-release data download? Now you have to validate and process serialized data.
The roster would be akin to say, XCOM’s roster, in which it expands based upon the number of people under your command and has no set limit, so there would be some fixed starting characters, but for the most part you’ll be acquiring new troops over time. (And losing them when they die)
Store the archetype/s for soldiers in a prefab, use data classes to drive the values on the prefab. Store the data in a format of your choice (json, xml). At runtime to load a soldier: instantiate the prefab, and apply the data. Keep a list or dictionary of soldiers (data) to be serialized with the game state. A serialization utility from the asset store may speed things up. Least that’s how I’m doing it.