Instantiating DialogueSytstemTrigger and setting its values in code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Instantiating DialogueSytstemTrigger and setting its values in code

Post by fkkcloud »

Hello,

I am trying to setup a way to instantiate DialogueSystemTrigger component runtime and set its DialogueDatabase and Conversation via my custom ScriptableObject.


1. What are the good method or variables to set DialogueSystemTrigger component's DialogueDatabase and Conversation in code?

2. In my custom ScriptableObject, what is a good way to set Conversation from a specific DialogueDatabase that I've selected? So I can set it to DialogueSystemTrigger later in runtime.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Post by Tony Li »

Hi,

You don't have to set the database. It's only used for the inspector to populate the conversation dropdown list. It's not used at runtime.

To specify the conversation, set DialogueSystemTrigger.conversation. Example:

Code: Select all

GetComponent<DialogueSystemTrigger>().conversation = "New Conversation 1";
BTW, if you're doing things from script, you don't have to use DialogueSystemTrigger. You can start a conversation manually using DialogueManager.StartConversation(). Example:

Code: Select all

DialogueManager.StartConversation("New Conversation 1");
fkkcloud
Posts: 298
Joined: Mon Oct 05, 2020 6:00 am

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Post by fkkcloud »

Hi,

So, if I have multiple DialogueDatabase, what should I do? or the conversation string need to be unique across all different DialogueDatabase?

I need to specifically set it as DialogueSystemTrigger since I am setting a scene with a specific dialogue/conversation.
Player will be starting the conversation on their demand rather than it starts right away.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Post by Tony Li »

Conversation titles (and all internal IDs, too) must be unique across any databases that are loaded into memory at the same time. See: Working With Multiple Databases.
Post Reply