Page 1 of 1
How to properly yield for an conversation to finish?
Posted: Tue Aug 13, 2024 12:49 pm
by Nefisto
Code: Select all
[SerializeField]
private DialogueSystemTrigger dialogTrigger;
protected override IEnumerator MyRoutine ()
{
dialogTrigger.OnUse();
// HERE
yield return dialogTrigger.WaitForFinish(); // <<- How to achieve a behavior like this??
// Dialog closed here
}
Re: How to properly yield for an conversation to finish?
Posted: Tue Aug 13, 2024 2:37 pm
by Tony Li
Hi,
Here are two ways:
1.
C# events:
Code: Select all
DialogueManager.instance.conversationEnded += OnConversationEnded;
...
void OnConversationEnded(Transform actor)
{
DialogueManager.instance.conversationEnded += OnConversationEnded;
Debug.Log("Conversation ended.");
}
2. Or polling:
Code: Select all
while (DialogueManager.isConversationActive) { yield return null; }
Debug.Log("Conversation ended.");