Page 1 of 1

Dialogue System Events in Code

Posted: Thu Dec 02, 2021 7:21 pm
by junwi21
How do I create the dialogue system events component in code?

I have NPCs that have dialogue system events for when a convo starts and ends but the problem is - they all have the same events so I want to hard code that instead of having to put a dialogue system component in and putting in several function calls for each NPC. How do I do this?

Re: Dialogue System Events in Code

Posted: Thu Dec 02, 2021 9:10 pm
by Tony Li
Hi,

You can add a DialogueSystemEvents component:
Spoiler

Code: Select all

var dialogueSystemEvents = gameObject.AddComponent<DialogueSystemEvents>();
dialogueSystemEvents.conversationEvents.onConversationStart(SomeMethod);
but it's probably better to just add the script methods directly:

Code: Select all

void OnConversationStart(Transform actor)
{
    // Do something when conversation starts.
}

void OnConversationEnd(Transform actor)
{
    // Do something when conversation ends.
}
//etc.