My Game has always required a database engine in two locations, one on the master server side to store user accounts and one on the game server side to store individual game details for persistence of game play.
I have daily experience with MySQL, PHP and web based development but my experience building a wrapper into a game engine that opens up the functionality of a database engine is limited. The good news? If I can do it, anyone can!
So I found these web sites:
http://www.mono-project.com/SQLite - This site details how to build a Mono project that wraps around SQLite Databse. It is simple and easy to understand.
http://msdn.microsoft.com/en-us/library/system.data.idbcommand.aspx - This site explains the command interface and how to make the calls.
http://forum.unity3d.com/threads/7866-Unity-and-Sqlite/page3 - This Unity Forum Thread has some great information in it that details how users fought the battle to implement a C# SQLite wrapper into Unity and they won!
http://forum.unity3d.com/threads/89658-C-SQLite-example-for-Unity-3-3 - This Unity Forum Thread is very informative but it shows a battle that was lost. At least there is information to gather from their efforts.
http://forum.unity3d.com/threads/28500-SQLite-Class-Easier-Database-Stuff - This is another great Unity Forum Thread that gives you a good battle to fight. It seems to work but it gave me the typeinitilizationexception error below! I was able to work through it though.
http://robertgreiner.com/2010/11/fixing-the-typeinitializationexception-was-unhandled-exception/ - Be warned - You are wrapping an external DLL so you may have some compatibility issues with the core of Unity and get some really strange errors. Just keep digging through the links above and you will get it working.
http://forum.unity3d.com/threads/31611-how-to-setup-a-database-in-Unity?highlight=free+sqlite - Another Unity Forum Thread - Interesting read and some links - It may not lead you anywhere though.
http://wiki.unity3d.com/index.php?title=SQLite - This was the first great resource to getting SQLite working within Unity that I found. Bad news? It is in Javascript, and while it works, I am writing my code in C# and it gets very messy when you try to call functions from one language to the other. So while this works great, and it may be perfect for you if you are writing in Javascript, I continued down my road of searching which lead to the links above. - Thanks to Alan Chatham for putting this together for the community! It is one of the best written step by step examples of how to get SQLite working in Unity.
Of course I can't forget to mention the main site you will need to visit:
http://www.sqlite.org/
If you are not familiar with Databases this will all be greek to you but if you are then you will love all of this! Even if you are not developing a game, just maybe some business software or whatever, SQLite is very powerful for its size and compact. Of course it is not the enterprise solution most high end solutions would use but for small stuff it is great.
If you are not familiar with all of this, wrapping .dll files in C# or Javascript and you still need some form of mass data storage, be sure to check out the following solution:
https://www.assetstore.unity3d.com/#/search/uniddata - It claims to be safe for all platforms, Webplayer games, iOS games, Android Games, and others so this, while it costs some bucks, sounds like a great solution and it gets high remarks from users.
At the end of all this.... I have:
1 Functioning Javascript SQLite implementation
2 Functioning C# SQLite implementations
1 FileIO example that I didn't even document but now that I have completed the SQL work, I am thinking I might need this basic FileIO just to write out some good logs to keep up with my project not only during building and testing but even after roll out, it would be nice to have logs I could get from users in different situations in a format that tells me all that I need to know.
My name is now in the database under firstName, lastName
Until next time!
No comments:
Post a Comment