Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create local database in unity3d

I'm planing to develop a game in Unity3D. I didn't choose yed if it will be in javascript, c# script or boo, as the developing languages that unity IDE offers.

In my game I need to store the game state : user name, level, game moves, current state, points and all the things that should be save. I want to enable the user to save the game in some certain time, and lets say that after couple of hours, when he wants to continue the game, he will be able to load the game from the point he stopped.

So I know that maybe I need 2 tables, one for the user data, and the other table for each game - to save the game state..

but I want to know if there is any option to add a local DB to Unity?

I saw this tutorial which describes how to serialize object in order to save the game state.. but I don't know if this will answer my game needs

like image 302
Elior Avatar asked Sep 04 '14 14:09

Elior


1 Answers

You can look at this unity answer for some help with using sqlite.

However in most situations i would use serialization instead of a local database.

The advantage of a database is thats you can easily search your data.

The advantage of serialization is that you can make your class structure the way you want it and the just save/load it without any need for adapters and parsing.

I would use a database if i had a lot of data, like thousands of rows. Or if my data has complex relations, ie lots of tables with relations between them. Otherwise i think its easier and less work to use serialization.

like image 97
Imapler Avatar answered Oct 20 '22 12:10

Imapler