OnConversationStart/End events

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
bidoofarmy
Posts: 2
Joined: Thu Feb 04, 2021 8:17 pm

OnConversationStart/End events

Post by bidoofarmy »

Hey,

I'd like to subscribe to conversation-starting and conversation-ending events through script so my game manager can know when to enter and when to exit its dialogue state — which is whenever any conversation starts or ends. I'm assuming they're static actions? I'd like to do something that basically amounts to this:

Code: Select all

using PixelCrushers.DialogueSystem;

private State state;

private void Awake()
{
     Wherever.OnConversationStart += EnterDialogueState;
     Wherever.OnConversationEnd += ExitDialogueState;
}

private void EnterDialogueState() => this.state = State.Dialogue;
private void ExitDialogueState() => this.state = State.Main;
From what I gather from documentation, something to that effect does exist but I can't seem to find these particular events — it doesn't appear I can access them from the DialogueManager or anywhere else. I'm probably missing something very obvious here, but search results unfortunately didn't help. Could you please help me out with that? That would be very much appreciated.

Cheers.
Last edited by bidoofarmy on Thu Feb 04, 2021 8:48 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnConversationStart/End events

Post by Tony Li »

Hi,

The Script Events & Messages section has that info. For the C# events:

Code: Select all

DialogueManager.instance.conversationStarted += OnConversationStarted;
DialogueManager.instance.conversationEnded += OnConversationEnded;

void OnConversationStarted(Transform actor) {...}
void OnConversationEnded(Transform actor) {...}
bidoofarmy
Posts: 2
Joined: Thu Feb 04, 2021 8:17 pm

Re: OnConversationStart/End events

Post by bidoofarmy »

Thank you very much for your quick response. Of course, that was it; I'm so used to events starting with "On" that I misread the doc and assumed the events themselves were named "OnConversationStarted". Problem solved. Cheers!
User avatar
Tony Li
Posts: 22049
Joined: Thu Jul 18, 2013 1:27 pm

Re: OnConversationStart/End events

Post by Tony Li »

Hi,

Glad to help! Microsoft's convention is that events usually take the form verbed, as in conversationStarted, and event receivers use the form OnVerbed, as in OnConversationStarted. However, that's not to say the rest of the Dialogue System is necessarily Microsoft .NET standard format. It largely tries to follow Unity's conventions instead, such as naming properties in lowercase such as DialogueManager.instance. Same with C# events, which is why it's DialogueManager.instance.conversationStarted with a lowercase 'c'.

Also, the Dialogue System takes advantage of Unity messages, so it supports a lot of useful Unity style message methods such as OnConversationStart and OnConversationEnd.
Post Reply