Creating simple database for assets (not SQL)

question no longer relevant

Whatever you do, stay tf away from XML. This is March 2021… nobody should use XML except maybe some massive national banks or perhaps oil companies.

If you must be external to Unity and love hand-editing text data, at least be kind to yourself and use JSON.

However, it’s probably best to try out some ScriptableObject tutorials on Youtube. ScriptableObjects are purpose-built for creating structured game content such as the cards in a card game, the weapons in your dungeon crawler, the guns in your FPS game, etc.

1 Like

Wrap it up in your own object (or interface) and pick one of the above and try it.

If you consistently only use that one object everywhere, then if you want to change the internal storage structure in the future, you just rewrite that one object.

Work through some JSON tutorials, it will almost instantly become obvious what is going on. It’s hard to get any simpler than JSON data, plus you can edit it with a text editor to find bugs while you’re developing.

Are you just looking for a savegame system? Because that’s not traditionally called a “database.” There are tons of tutorials for those, but here’s my own scribblings:

Load/Save steps:

I guess for first implementation, stick them all in memory, then flesh out the rest of the class and actually see it working. Once you’re confident it is truly working, then you can reason about how big stuff is and where it might go. It might be reasonable to write separate files, or write a single file with everything. It’s going to be highly database dependent and obviously answers would be different between:

  • there are 10 cards
  • there are 10,000,000,000 cards
  • each card is 24 bytes
  • each card is 24 megabytes

Answer those questions by getting it running first, then see what you’re up against.

1 Like

That’s only for in the editor, not for actual running code. I assumed you are writing a game.

Are you writing a game or are you writing editor scripts? There is a world of difference, two completely different approaches designed to do completely different things.

I recommend you work through some basic tutorials involving Resources.Load and just generally how Unity is structured. Everything about the API above has complexities that I cannot even begin to type to you here.

1 Like