Create Database at runtime

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Hausl
Posts: 8
Joined: Thu Mar 06, 2025 4:05 am

Create Database at runtime

Post by Hausl »

Hello there!

I currently have the following setup:

I use a database with all actors/conversation/quests/variables..., and a second database which syncs the quests/items and variables from this database, which I want to call on the server, for every user connecting to the game, so I can achieve server authority for the quests and variabless.

I do this that because I want to save and load data on the server with:

string s = PersistentDataManager.GetSaveData(); // Save state.
PersistentDataManager.ApplySaveData(s); // Restore state.

because i can easily save the string in my db for the user.

Right now it works, but only if I use the dialogue manager which calls the database.
How excactly would I call the database at runtime, without creating too much overhead?
If I want to call the database instance ready to save and load, what would i need to do here?
I already tried to use .AddDatase, which loads the database, but I cant save and load then.

What am I missing?

Thank you for your help, I really appreciate this forum!
User avatar
Tony Li
Posts: 22886
Joined: Thu Jul 18, 2013 1:27 pm

Re: Create Database at runtime

Post by Tony Li »

Hi,

At runtime, all databases are merged in memory into a single DialogueManager.masterDatabase. So when you call PersistentDataManager.GetSaveData() it returns a string containing all of the data you've specified in the Dialogue Manager's Persistent Data Settings. To keep the string small for network traffic, you can untick all of the "Include ***" checkboxes. Then the save data string will only include quest states and variable values.

It sounds like you really only need one database. However, if you have two or more databases, I recommend loading the extra databases by adding an Extra Databases component to the Dialogue Manager. This will merge them all in memory into DialogueManager.masterDatabase, which you can then save and load as I described above.
Post Reply