So I have a game with a lot of trivia questions, whereas every question has 4 possible answers. I was wondering how to approach it in terms of database…I’ve used mySQL in the past so I’m familar with that. I also figure XML can be an option. But I wonder… what method would you use for something like that?
Any references with tutorials would be greatly appreciated.
Depends on a few things. Strictly speaking, XML is probably the quickest to get up-and-running, and the easiest to share and edit externally, because just about everyone is familiar with XML files and there are free programs to edit the data everywhere. That said, it’s an abnormally large addition to your game for the use of just a handful of functions from System.XML. (Like 1MB I think?) It’s also pretty slow to access I think because it’s all strings/text data.
JSON has most of the benefits of XML but it has a longer set up time, is more complicated, and generally you have to use a third-party tool in order to share and/or edit the data externally if you want to go that route I think. It’s far smaller and faster to access, I hear, once you do actually get it running. I admit I’d never actually used it, so I’m not that familiar with it.
(Can’t find a quick link to this one, and have to go)
The old internal-Unity method was to make a data-container class, like “QuestionData”, and a script that’s just “List of those data objects”. You’d then slap that list script on an empty GameObject, make a prefab out of it, delete the scene object, and then add all of your data to the prefab (in the inspector) to form a little database. When/where the database is needed, you’d just make a public GameObject reference on some manager in your scene and drag that prefab in there in the inspector and use the data directly- you’d never instantiate it. The problem with this is that the database data is all held in the magic limbo of inspector-set values. This always bugged me. It’s also hard (or impossible, maybe?) to edit externally, it feel hack-ish, it isn’t very versatile, etc…
The new internal-Unity method (ScriptableObjects) takes a bit more setup than the old one, but it fixes the great majority of the problems. It’s still next-to-impossible to edit from outside of Unity, but assuming that you don’t need to, it’s definitely a strong option.
First off thanks a lot for the detailed feedback, Lysander, I really appreciate it.
I’ll try the ScriptableObject method, since I’m not really looking to edit outside of Unity. I’ll watch the tutorial you linked.