I'm trying to make a simple game database, containing simple items.
My database is simply a ScriptableObject, containing a list of other ScriptableObject (Items) that holds informations about items and hold a string key.
var item = DB.GetItem("weapon.magic_sword");
1 - Is there a better solution than using key string to identify items ?
2 - If I want to have generated item. For instance adding randomly stats to existing "templates" item, am I forced to create a MonoBehaviour script for Item and instanciate this from the template scriptable object ? I use streaming assets to save the inventory of the player, so I need to be able to use those generated item in streaming assets.
PS: I prefer avoid a real database (such as sql)
I'm going to break down your question:
ScriptableObject
can't be used to implement an actual DBScriptableObject
is great for storing meta data on items (base armor, damage, cost, etc)PlayerPrefs
. We use JSON.NET and store it as a string; if you want to be more optimized/secure, you can use some binary serialization (Protobuff, built in binary serialization, etc)GUID
to each object and get/set it by it's unique ID.I hope I understood your question correctly and answered it.