Page 1 of 1

Setting Database By Code

Posted: Tue Nov 07, 2017 6:48 am
by patxiku
Hi, I'm having a "nullreference exception" error while setting a database inside my script.
The database is correctly referenced and I use the "dialogueSystemController.AddDatabase()" method to set it.
Is this the proper way of doing this?
Thanks in advance.

Re: Setting Database By Code

Posted: Tue Nov 07, 2017 10:18 am
by Tony Li
Hi,

Can you use DialogueManager.AddDatabase(DialogueDatabase)?

For example, say you have a dialogue database asset named DB1 in a Resources folder. You can load it into the Dialogue System like this:

Code: Select all

using PixelCrushers.DialogueSystem;
...
var database = Resources.Load("DB1") as DialogueDatabase;
if (database != null) DialogueManager.AddDatabase(database);
There are some other examples on this forum of converting articy:draft and Chat Mapper files at runtime into databases and then adding them, as well as creating a database from scratch in code using the Template class. (To use the Template class, create an instance by calling Template.FromDefault(). Then use the Template methods such as CreateConversation to create a new conversation that you can add to the database.)

If you're still getting an error, would you please click on the error message in the Console window, press Ctrl+C to copy it to the clipboard, and then paste it into a reply? This will include the full stack trace that should help identify the issue.

Re: Setting Database By Code

Posted: Thu Nov 16, 2017 3:10 am
by patxiku
Thank you!