Page 1 of 1
Universal Dialogue State
Posted: Sun Apr 03, 2022 6:23 pm
by boz
Is there a way, for example, to detect if the Dialogue Window is currently open and active?
Like if I wanted to prevent things from happening in the game if the dialogue window is open, how might I do that?
I feel like I saw some sort of DialogueSystem.dialogueWindowIsOpen or something somewhere, but I can't find it now.
Re: Universal Dialogue State
Posted: Sun Apr 03, 2022 6:28 pm
by boz
Wait, wait, I think I found it: DialogueManager.isConversationActive
Is this the best way to do this?
Re: Universal Dialogue State
Posted: Sun Apr 03, 2022 7:47 pm
by Tony Li
Hi,
Yes, that's a way to check if you only need to check once -- such as if the player has pressed a button to open a menu or perform some action.
If you need to check every frame, there's an alternative. You can register methods with the C# events DialogueManager.instance.conversationStarted and conversationEnded, or add a script with OnConversationStart and OnConversationEnd
special methods to the Dialogue Manager.
Re: Universal Dialogue State
Posted: Mon Apr 04, 2022 4:34 pm
by boz
Oh wow, can I use those like this?
Code: Select all
OnEnable()
{
DialogueManager.instance.conversationStarted += DoThing;
}
Re: Universal Dialogue State
Posted: Mon Apr 04, 2022 4:37 pm
by Tony Li
Yes, absolutely. A common setup is:
Code: Select all
void OnEnable()
{
DialogueManager.instance.conversationStarted += DoThing;
}
void OnDisable()
{
DialogueManager.instance.conversationStarted -= DoThing;
}
On the other hand, if you only want to do something once for a single conversation, you can do this:
Code: Select all
void OnEnable()
{
DialogueManager.instance.conversationStarted += DoThing;
}
void DoThing(Transform actor)
{
DialogueManager.instance.conversationStarted -= DoThing;
// Do the thing here....
}
Re: Universal Dialogue State
Posted: Mon Apr 04, 2022 4:52 pm
by boz
Perrrfect, thank you!
Re: Universal Dialogue State
Posted: Mon Apr 04, 2022 5:03 pm
by Tony Li
Happy to help!