Page 1 of 1

Instantiating DialogueSytstemTrigger and setting its values in code

Posted: Sat Oct 10, 2020 3:25 pm
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.

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Posted: Sat Oct 10, 2020 4:21 pm
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");

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Posted: Sat Oct 10, 2020 4:38 pm
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.

Re: Instantiating DialogueSytstemTrigger and setting its values in code

Posted: Sat Oct 10, 2020 9:16 pm
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.