Dialogue System Events in Code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
junwi21
Posts: 35
Joined: Wed Jan 27, 2021 12:18 am

Dialogue System Events in Code

Post 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?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: Dialogue System Events in Code

Post 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.
Post Reply