Making a visual database?

This isn’t something I’m really considering, or wanting to make at the moment, but it would definitely be useful if I were to ever make a sequel for a game (or another game entirely) which uses the same item handling system (database).

I know there are quite a few visual database systems on the asset store, some of which are even free. But I’d prefer having a system which I fully understand and can alter easily.

So, how hard (and time consuming) would it be to turn a database into a visual one (making a datbase, and then making it editable via an editor window? Or make a visual database entirely from scratch?

The main thing I would need, is to be able to add and delete an item, and be able to set its type (consumable, weapon, armour, etc.), and then edit the stats (HP, Damage, etc.).

How hard would this be to make?

Not terribly hard. ScriptableObject is the magic class at the core of most, if not all of these. It’s a popular choice for randomised loot - make template objects and perhaps a custom editor panel for them so you can make different ones with a dropdown for special rules to generate attributes.

The core system shouldn’t take you long, the editor a little longer and the bulk of your time will be making items and tweaking in-game generation, probably.

2 Likes

Funny you should ask… I’m actually working on that very thing at the moment. To be honest, the hardest part has been the custom editor windows because I personally can’t stand Unity’s API for developing them.

I still have some design decisions to make as well. In my case I’m not using ScriptableObject, but rather doing all of my own binary serialization for the data structures and also generating classes to match the database tables and making it exportable so a database can be exported as a unitypackage and imported into a new project. I’m also building in saved query support so you can save queries and have it return objects for you (though I don’t know if that’ll make release 1) and relationships so you can have objects with collections of objects stored in separate tables.

There are already other database systems out there, like SqlLite but my goal is to build something that can easily be stood up and managed directly in-editor. I can already see a few things that will be challenging though, such as the data being binary so it makes merges difficult, so I need to put some thought around an eventual solution.

1 Like

Approach I’ve used on several games now. This is a setup for multiplayer games.

First, make your data classes plain old objects, not unity classes. Ideally in a dll you share between server/client. I usually manage this from the server VS project. Make a class that has lists/dictionaries of all of these data objects. I call mine StaticData.

Get Odin inspector, seriously makes the ui part of this easier, plus it supports dictionaries which is worth the cost just for that.

Use the same serialization that you will be using everywhere. I standardized on protocol buffers years ago. Having multiple serialization formats, I can’t think of a good reason for that really.

Create scriptable objects that have the same data classes that StaticData contains. I usually have multiple just for organization. Server side you don’t need that, you just want the one StaticData ‘master’ class.

Make an editor button that creates a new StaticData, populates it from your scriptable objects, and saves it to a file accessible by your server. This file I usually commit to source control on the server. On the client in production it goes into the main/first asset bundle the client loads.

At runtime on the client, use the same logic that you used to save off the StaticData, to create an instance for runtime use. Again, your runtime doesn’t need to be accessing the data from multiple scriptable objects, that’s there for data entry organization.

1 Like

Only reason I’m doing my own custom serialization for my deal is so it’s not deterministic.

1 Like