Data storage for games

Hi all,

How do you store data for your games? Such as levels sructure for dynamic composition, tables of game variables, parameters for various game objects e.t.c.
When making games with Director in the past, i used external database called Valentina. It was great, because it keeped all data in one place in tables that was easy accesable with SQL queries, and it was really handy for game designer to tweak balance of game.

So, how do you do it in Unity?

There is a word in there that counteracts what you are saying… “dynamic”

You would store all of your data either in a database, or text file, or xml, or whatever you want to read. This data should point to active prefabs (or you will have to write import scripts to get the data into unity) It should store position’s, orientations and scale.

If you are looking for more dynamic, you will need to put together a set of data with points of connection and then build the code it takes to recognize a point, and what can go with it.

Either way is acceptable.

ahhh…i wanted to answer this… but you win BigMisterB…
MySQL database or playerPrefs…

BigMisterB: By “dynamic” i mean “not stored inside the scene”, sorry for poor word choice. Composition is just one type of data, and i’m looking for a handy way of storing all of it. Strings are not structured, XML are hard to edit and tweak, so database is the best approach, i think. What databases are usually used with Unity? I believe it’s MySQL for web build, but what about stand-alone and mobile?

Aspiration: PlayerPrefs is the way to store settings in linear list, and it’s not i’m talking about. I’m talking about storing tables of parameters with possibility to edit them externaly. Do you know what database shoul i use for not web-based games?

one of my friend used MySQL database for a database driven game and it worked fine…

For a “local” game (non-web based), I wouldn’t recommend something that requires a “server” component to be installed and/or maintained by the User of your game. For that reason alone, if you want a SQL-based storage mechanism, I’d recommend SQLite. It’s tiny, self-contained, and very fast.

Or, you can save directly from the editor to a file or database on the server.
For local games or web-based games load from server (and the files and data from the database).
MySQL is much faster if you use stored procedures.
If the game include auto-update - easy to add a mesh, textures, etc. as needed.

I heard aboit SQLite, though never used it myself. It appears it’s only solution available on all target platforms, including mobile. Is there any examples how to use it in Unity?

McRain: I don’t think it’s a good thing to require persistent internet connection for a local game.

It is not necessary - a persistent Internet connection.
Store all data directly in files.
Internet connection is necessary only if you have a server (for example) to display the TOP-100, or to update the game.

ba - is byteArray . You can get it via MemoryStream or via other way

Or FileStream will not work in iOS or other target platforms?

I’ve misunderstood your answer above, it can be read as you propose to load all from a server. :slight_smile:

It all depends on your game and your plans for your game))
IMHO: Do not deny the possibility that the later the game will be full on-line)

We just released Siaqodb- local database solution for Unity3D: http://siaqodb.com/?p=482.
Demo contains a lot of examples, it has very simple API,it is very fast, small footprint, etc…

Maybe it’s a good solution, but what i really want is more functional database editor app. With database creating, structure editing, ODBC import and so on.

As with any database application where you are starting from scratch, you would need to build those tools yourself. I doubt there is a “usable” premade application just sitting there waiting for you to use it.

To further complicate things you also would need to figure out what all the relationships in your database are. How they interact with each other and so on. All of that is redone almost every time you create a new project.

I think this tool shoud be part of purchased solution. It’s already there, database editor included in the package, it’s just not so functional - as far as i’ve seen it can only edit values in existing database.

P.S, I’m talking about Siaqodb thing posted above.

@Lisan,
With SiaqodbManager you can Insert, Edit and Delete objects, you just need to define your .NET Types you want so save and then you can manage objects of that Types.

That’s what i am talking about. You can’t create database from scratch, add fields, import data from other sources - that’s you usually expect from database manager application. It’s all can be done from the code of course(except for import), so it’s not fatal, just not so handy.

Well…depends on your needs of course, but in general in game development (just curious) why would you need to manage a local database by a tool? I mean those databases are on users machines where game is running, so will be used only by game. Ok, it may needed that you provide a “start-up” database where it is stored initial data ( but this can be created easy by a simple start-up method isn’t it?). About import/export…for other platforms we have XML Import/Export but we removed from Unity3D version because it depends on System.XML which has biiig footprint and for phones games, size of app matter a lot, we removed also because we consulted (before port) some Unity3D developers and they confirmed import/export is useless for games in general because there is not big amount of data to manage.

I was working in Director before, and used Valentina database engine. My game designer had no need at all to run Director itself, he did all game balance tweaking in MS Access database, then in one click it was converted to Valentina database via import, and then he need only to run game build to see results. That’s it, if you have handy editing tool, you can manage database without even having Unity installed.

just thought i’d mention this, if your writing to disk make sure you use Appication.persistentDataPath
You’ll need to do this for IOS/Mac at least where you cannot write inside the application folder. Not sure how it works on web games though on windows it stores it into application data.