Calling a method on every conversation

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
cptscrimshaw
Posts: 113
Joined: Sun Sep 20, 2020 8:21 pm

Calling a method on every conversation

Post by cptscrimshaw »

Hi Tony,

1. I have a built-in time manager that is completely separate from the Dialogue System, and I'd like to call a method (this method exists and works fine) to pause at the start of ANY conversation and unpause after the conversation is over. Is there a place I can do this globally so I don't have to add the method calls to every conversation?

I looked through the forums and found some ideas, but they all seemed a bit more involved than what I'm looking to do, but apologies if I missed something.

2. Unrelated to the above question, when starting dialogue with DialogueManager.StartConversation("dialogue name", actor, conversant), what's the best way to pause the game during the conversation like you would with a Dialogue System Trigger?

Thanks!
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Calling a method on every conversation

Post by Tony Li »

Hi,

For both cases, add a script to the Dialogue Manager that has OnConversationStart and OnConversationEnd script messages. Example:

Code: Select all

using UnityEngine;
public class PauseTimeManagerDuringConversations : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    {
        // Your code here to pause your time manager.
    }
    void OnConversationEnd(Transform actor)
    {
        // Your code here to unpause your time manager.
    }
}
Alternatives:
  • Add a Dialogue System Events component to the Dialogue Manager, and hook up the OnConversationStart() and OnConversationEnd() UnityEvents to your time manager (assuming it's accessible as a DontDestroyOnLoad component or ScriptableObject asset).
  • Or hook into the DialogueManager.instance.conversationStarted and conversationEnded C# events.
Post Reply