- Home /
saving inventory to database
Hi all,
got an inventory script working quite nicely where you can pick up items and have them appear in a bag, delete them from the bag etc. Picking up and deleting items also updates the user's inventory table in the database. All working fine but I am unsure how to restore the inventory state when they log back into the game. Obviously I can load all the item data from the database and populate the inventory array with the data but the part I'm not sure about is displaying the the item's 2D texture in the bag again. Is there a way to somehow store the item's Texture2D object in the database as well or should I just create a massive array in Unity with every item's ID and 2D texture and when the saved data is loaded from the database find a match with the ID and grab the texture?
Thanks in advance Bill
Answer by ron3fp · Sep 09, 2010 at 02:41 PM
I would use the second approach. Saving only the necessary information in the database (item ID) even if it was a database supporting binary objects. Use a hashtable (key / value pairs) to retrieve the texture to the item on load.
Answer by cristoph1 · Jul 19, 2011 at 02:03 PM
you can use Siaqodb http://siaqodb.com/?p=482 true database solution for Unity3D, simple, fast, small footprint
Answer by Bill 2 · Sep 09, 2010 at 11:50 PM
cool - thanks for your thoughts.
just a note Bill, please use the "comment" field on peoples answers. These forums arent "old facion forums". You might receive "down votes" for answers like this one. Votes = reputation = options in the forum