Tapping into DialogueSystem Events Globally from Code

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Tapping into DialogueSystem Events Globally from Code

Post by Itilos »

Hello!

Is there a way to easily tap into DialogueSystemTrigger events via code?

I know you can set up events and assign Gameobjects, but I am looking to (for example), always hide the player UI when conversations start. Rather than assigning an action to every trigger to do that in every scene - is there a way I can tap into the OnConversationStart via script, so my UI knows that when that fires, it should always disable?

I'm trying to figure out what the intended way of interfacing with this is.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tapping into DialogueSystem Events Globally from Code

Post by Tony Li »

Yes, add a Dialogue System Events component to your player. Configure the OnConversationStart() UnityEvent to hide the UI. Configure OnConversationEnd() to show it again. Your player should be the active conversation's actor or conversant for this to work. For more info on GameObject assignments, see: Character GameObject Assignments. For a video explanation, see 07:00 of the Interaction Tutorial.

Alternatively, hook into the C# events DialogueManager.instance.conversationStarted and conversationEnded.
Itilos
Posts: 21
Joined: Thu Oct 20, 2022 12:03 am

Re: Tapping into DialogueSystem Events Globally from Code

Post by Itilos »

Thank you! This was super helpful.
User avatar
Tony Li
Posts: 21681
Joined: Thu Jul 18, 2013 1:27 pm

Re: Tapping into DialogueSystem Events Globally from Code

Post by Tony Li »

Glad to help!
Post Reply