I need a way to load some basic sets of data. What’s the way to do this in Unity in an elegant way?
For example there are Cards in my Game, just like in TCGs:
Name
Health
Picture
etc.
Should I create Prefabs for every card?
Is there a way to create a master prefab serving the data structure and then to instance it in order to create prefabs for every card in the game?
Normally, I’d create a database or text file, but I’m not sure whether that’s a very “integrated” way.
I would make one prefab ‘Card’ and set different textures on it, have script to hold different data (name, health, description, blah blah). You can either have a script on this prefab access the data, or have a ‘card manager’ class which wrangles data and dishes it out to cards.
DB or text file, or serve it from a site (get via WWW). Depends on your needs. If you want to update things easily, probably any of those. Maybe XML or json format. If you want to change things after deployment (live update), use WWW. If it needs to be baked in, you could either edit each card by hand (modifying instances of prefabs that is). I myself would probably have an editor script that reads a CSV (Excel) file and populates the prefabs, if I were to be baking data in like that. Then you can modify the Excel sheet and reimport that as needed, and you wouldn’t need to distribute (deploy) the Excel sheet with your game.
FWIW: You can actually nest prefabs, but it’s not pretty. They are working to make that better.