Page 1 of 1

Run time swapping of default database

Posted: Thu Jan 09, 2025 1:27 am
by kashifWajidRG
My use case is as follows:
- The game is developing, so many people are working on different variations.
- To support this we are creating a versioning system for our game, which versions the metadata and the dialogues according to the metadata.

Question:
- Can we at run-time load a Dialogue database asset? I know about the adddatabase method, but that is just to add a database as an extension right? I want to completely override the default database based on the version of the game that is running.
- If yes to the above question, should we export the database as a unity asset, or export it as a CSV and then load it at run time?

PS: The database asset cannot be marked addressable, as the version system is our own.

Re: Run time swapping of default database

Posted: Thu Jan 09, 2025 8:00 am
by Tony Li
Hi,

Yes, you can remove the initial database and add a new one (even if it's the same one but updated at runtime). Here's an example of updating a database at runtime from articy:draft:

Code: Select all

// Convert the latest articy:draft project into a dialogue database:
var xmlData = System.IO.File.ReadAllText("D:\\Data\\MyArticy.xml");
var importedDatabase = ArticyConverter.ConvertXmlDataToDatabase(xmlData);

// Replace the runtime database:
DialogueManager.RemoveDatabase(DialogueManager.instance.initialDatabase);
DialogueManager.AddDatabase(importedDatabase);

// Update quest UIs in case the new database has different quest text:
DialogueManager.SendUpdateTracker();
Alternatively, you could Use Multiple Databases, one for each writer, so they won't step on each others' toes.

Re: Run time swapping of default database

Posted: Thu Jan 09, 2025 11:52 pm
by kashifWajidRG
Thank you for the prompt response. One more question though: So which format is better to export the database? For now its a Unity asset, should I export it as CSV? and then load that in memory at runtime?

Re: Run time swapping of default database

Posted: Fri Jan 10, 2025 7:58 am
by Tony Li
Hi,

If you can export the Unity asset, that will do the best job of keeping it intact. Otherwise export to Chat Mapper XML.

If your writers are going to be writing in an application outside of Unity, I strongly recommend one of the applications that the Dialogue System can import natively, such as articy:draft, Arcweave, or Gem. (There are others, too.)