Forum rules - please read before posting.

OnSpeechToken event not triggering

edited January 2021 in Technical Q&A

Hello,

We're currently trying to tap into the capabilities of the speech event tokens and as far as we can tell we have set up everything correctly as per the documentation; however, no matter what we do we cannot get the OnSpeechToken event to ever trigger. Here is a snippet of how our code is setup:

**

using UnityEngine;
using AC;

public class SpeechTokenMonitor : MonoBehaviour
{

private void OnEnable()
{
    KickStarter.dialog.SpeechEventTokenKeys = new string[1] { "test" };

    EventManager.OnStopSpeech += OnStopSpeech;
    EventManager.OnCompleteSpeechScroll += OnCompleteSpeechScroll;
    EventManager.OnSpeechToken += OnSpeechToken;
}

private void OnDisable()
{
    EventManager.OnStopSpeech -= OnStopSpeech;
    EventManager.OnCompleteSpeechScroll -= OnCompleteSpeechScroll;
    EventManager.OnSpeechToken -= OnSpeechToken;
}

private void OnCompleteSpeechScroll(Char speakingCharacter, string speechText, int lineID)
{
   AC.ACDebug.Log($"Speech Line# {lineID} done for char: {speakingCharacter.name}");

}

private void OnStopSpeech(Char speakingCharacter)
{

}

private void OnSpeechToken(Char speaker, int lineID, string tokenKey, string tokenValue)
{
    AC.ACDebug.Log("token found in speech");

    if (tokenKey == "test")
    {
        AC.ACDebug.Log("expression token found");
    }
}

}

**

We have this script hooked up to a UI prefab that gets dynamically loaded upon any dialogue speech occurring (ie our custom speech visual bubble hooked up via the Menu Manger / subitles sub menu)

Here is an example line of speech text we have setup in an Action List Asset / Dialogue PlaySpeech action list event

[test:neutral]Hello test token world

Given this setup, and given that the script defined above is hooked up to our UI prefab object that gets dynamically loaded we would expect that the OnSpeechToken function would trigger when the dynamically loaded object is created. And we would also expect when the piece of speech listed above plays that the [test:neutral] would be recognized. However, not only does the OnSpeechToken event not fire off on the dynamically loaded object but the token isn't removed from the dialogue and thus it all shows up when the speech plays

Is there something special we have to do when registering the tokens with KickStarter.dialog.SpeechEventTokenKeys

Should we do that separately in some form of static scene object ahead of time as opposed to setting this field on an object that is getting dynamically loaded? We're really not sure what is going wrong

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.