Page 1 of 1

DialogueManager.PlaySequence() not triggering OnSequenceStart \ OnSequenceEnd events?

Posted: Tue Oct 20, 2020 4:56 am
by LostTrainDude
[Unity 2019.4.12f1 - DS v2.2.11]

Hi Tony!

I'm still playing around with the different events in order to create a chain of sequences. In other words I want to:
  • Run a sequence
  • Wait for it to finish
then repeat the process.

Attempting to do so, I noticed that the OnSequenceStart \ OnSequenceEnd events seem to only be triggered when Sequences get called from within a Conversation. If in a custom C# script I include either DialogueManager.PlaySequence() or DialogueManager.instance.PlaySequence(), the referenced sequences would run, but I don't get any event back.

FWIW, I have ticked the Inform Sequence Start And End tickbox in the Dialogue Manager and also attached to it a custom "event broadcaster" script that for each of the events invokes a custom event.

Code: Select all

using UnityEngine;
using PixelCrushers.DialogueSystem;

public class DialogueSystemEventBroadcaster : MonoBehaviour
{
    public delegate void Delegate_OnConversationStart(Transform actor);
    public static event Delegate_OnConversationStart onConversationStart;

    public delegate void Delegate_OnConversationEnd(Transform actor);
    public static event Delegate_OnConversationEnd onConversationEnd;

    public delegate void Delegate_OnSequenceStart(Transform actor);
    public static event Delegate_OnSequenceStart onSequenceStart;

    public delegate void Delegate_OnSequenceEnd(Transform actor);
    public static event Delegate_OnSequenceEnd onSequenceEnd;

    public void OnConversationStart(Transform actor) => onConversationStart?.Invoke(actor);
    public void OnConversationEnd(Transform actor) => onConversationEnd?.Invoke(actor);
    public void OnSequenceStart(Transform actor) => onSequenceStart?.Invoke(actor);
    public void OnSequenceEnd(Transform actor) => onSequenceEnd?.Invoke(actor);
}
The above code works, meaning that I am able to have methods subscribe to each of these events (that's how I found out the OnSequenceStart \ OnSequenceEnd seem not to trigger outside of Conversations). I was also wondering if there was a way to pass the Sequence as a string, rather than the Actor's Transform.

Am I missing something?

Thanks a lot in advance, as always!

Re: DialogueManager.PlaySequence() not triggering OnSequenceStart \ OnSequenceEnd events?

Posted: Tue Oct 20, 2020 10:26 am
by Tony Li
Hi,

DialogueManager.PlaySequence() has several variants. One of them has a parameter to specify whether to inform participants when a sequence starts/ends:

Code: Select all

PlaySequence(string sequence, Transform speaker, Transform listener, bool informParticipants)
There isn't a built-in way to pass the sequence as a string. You could write a wrapper for DialogueManager.PlaySequence() that records the sequence string in a variable so you can reference it later.

Re: DialogueManager.PlaySequence() not triggering OnSequenceStart \ OnSequenceEnd events?

Posted: Tue Oct 20, 2020 11:00 am
by LostTrainDude
Tony Li wrote: Tue Oct 20, 2020 10:26 am DialogueManager.PlaySequence() has several variants. One of them has a parameter to specify whether to inform participants when a sequence starts/ends:

Code: Select all

PlaySequence(string sequence, Transform speaker, Transform listener, bool informParticipants)
Thank you, it seems to be working!

I wrongly assumed that PlaySequence would automatically play "by the rules" set in the Dialogue Manager regardless and didn't think to try the different variants :roll:

Re: DialogueManager.PlaySequence() not triggering OnSequenceStart \ OnSequenceEnd events?

Posted: Tue Oct 20, 2020 12:48 pm
by Tony Li
The Dialogue Manager's checkbox only applies to sequences in conversations. I think that note is tucked away in a tooltip; sorry for the confusion.