Event containing EventArgs at the start of each node

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
circusCharlie
Posts: 8
Joined: Thu Apr 29, 2021 1:48 pm

Event containing EventArgs at the start of each node

Post by circusCharlie »

Hi,
I have setup some dialogue entries in my template and I set different values of these entries at every node. Is there a way to get a callback containing the event args (using which I can extract my values set at that node) at the start of each node? Currently I could only find OnResponseSelected but that works only for the response nodes.

Thank you
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Event containing EventArgs at the start of each node

Post by Tony Li »

Hi,

By 'template,' do you mean you've added fields to the Dialogue Entries template in the Dialogue Editor's Templates section?

If so, you can add a script with an OnConversationLine(Subtitle) method to the Dialogue Manager or either of the primary participants. (See Script Messages for details.)

For example, say you've added a Text field named "Mood". You can access it like this:

Code: Select all

using PixelCrushers.DialogueSystem; // (Add to top of script.)
...
public void OnConversationLine(Subtitle subtitle)
{
    string mood = Field.LookupValue(subtitle.dialogueEntry.fields, "Mood");
    Debug.Log("Current node's mood is: " + mood);
}
circusCharlie
Posts: 8
Joined: Thu Apr 29, 2021 1:48 pm

Re: Event containing EventArgs at the start of each node

Post by circusCharlie »

Hi, thank you so much for the reply. Do I need to add this method to a monobehavior and attach that to the dialogue manager?

Is there any other way for example subscribing to an action or getting some sort of a callback on my non-monobehavior classes?

Thank you
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: Event containing EventArgs at the start of each node

Post by Tony Li »

For non-MonoBehaviours, you can hook into the C# events.
Post Reply