Page 1 of 1
Event containing EventArgs at the start of each node
Posted: Tue Aug 03, 2021 2:36 am
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
Re: Event containing EventArgs at the start of each node
Posted: Tue Aug 03, 2021 9:09 am
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);
}
Re: Event containing EventArgs at the start of each node
Posted: Tue Aug 03, 2021 10:19 am
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
Re: Event containing EventArgs at the start of each node
Posted: Tue Aug 03, 2021 10:38 am
by Tony Li
For non-MonoBehaviours, you can hook into the C# events.