Why I probably won't use SQLite again with Unity
That title may not be entirely truthful but you'll get what I mean in a bit. So I was in charge of implementing the data storage for card inventories, decks, unlocked items, player data etc in Void. This was something I hadn't really done before aside from using Unity's Player Prefs. We didn't really have much of a criteria for what the database needed to do aside from be more secure than PlayerPrefs. After doing some research I chose to use SQLite because it is compatible with Android (our target build platform) and stores databases locally so the player would never need an internet connection to play the game.
As far as implementing SQLite I followed this fantastic article . After making my own adjustments I felt pretty confident that I'd made the right choice. Fast forward time to about halfway through the development of Void and my mind had changed significantly. Every time I wanted to implement a new table with specific data sets I had to spend a good chunk of time setting it up to work right. Alternatively if I had used JSON I could have just made my data class serializable and stored it without having to fumble with specifics of which fields to store and typecasting when reading and writing from the database.
Hassles aside, the other criteria we had was that the database needed to be stored locally so that the player didn't need an internet connection to play. Why did we decide this was a criteria? No idea. The internet is so ubiquitous this criteria just limits what we can use and how secure our data will be. Disregarding this criteria means I could have used Google Firebase to store data. Google Firebase would have allowed us to set up User Authentication easily, would have ensured our data was largely more secure due to it not being directly exposed to the player and would have allowed me to use JSON meaning a simple matter of just Serializing classes again.
This is just my experience with using SQLite for the purposes of a deckbuilding game and I may super wrong about some of these points so please correct me if so. My biggest issue was that as the project scaled up and grew SQLite was time consuming to update and maintain.
If you're reading this and are thinking "Why didn't you just use x or do y dummy?" Then please let me know! Always keen to learn better ways to do things!
Leave a comment
Log in with itch.io to leave a comment.