Forum rules - please read before posting.

ActionList when turn on, on Subtitles Menu acts weird...

Hello,

I have a button which I want to deactivate its interaction when subtitle menu is launched.
So I created a custom action that changes interaction of the button (true/false) and I run it on "ActionList when turn on" and "ActionList when turn off" of the menu.

The first time the subtitle menu appears works. But when I press next and goes to the second Dialogue it runs the "ActionList when turn off" but doesn't re-run the "ActionList when turn on"  and the button stays activated.

How exactly the dialogue system works?

My setup is Display Subtitles forever until user Skips it and I use a button with Input Axis : SkipSpeech

Is there any other way to disable interactivity of a button when certain Menus are opened?

Thank you

Comments

  • Are you talking about a Unity UI Button or AC Button element?  Without seeing the exact code you're running, it's hard to diagnose much.

    There are alternatives to the "When turn on/off" ActionLists however - you can use events, which - since you're using a custom Action - would probably be the better choice anyway.

    See the Manual's "Custom events" chapter.  There's two that you can try:

    OnMenuTurnOn (Menu menu, bool isInstant);
    OnStartSpeech (AC.Char speaker, string speechText, int lineID);

    If you used the OnMenuTurnOn event, you can just check for the menu's title, i.e.:

    if (menu.title == "Subtitles")
    {
      // Do something
    }

    A tutorial for using the OnStartSpeech event can be found here, but the principle applies to all events.
  • I'm using a UI Unity Button
    Question : when you add several Dialogue Play Speech actions in sequence on an ActionList, those actions work continuously? I mean.. the first Dialogue opens the Subtitle Menu and the others follow without closing it? or each action opens / close the menu? The "ActionList when turn off" option runs for each one or only for the last one?

    I'm gonna try thought the OnStartSpeech and see if it works. Thank you!


  • edited May 2018
    I tried the OnMenuTurnOn and again the same thing happened.. When the first Dialogue: Play Speech runs, it works and deactivates the button. Then when I click the next button and loads the second Dialogue the button re-activates.

    From the Logs when I press next and runs the second action Play Speech from what I see is that first runs the OnEnable for the second Subtitle Menu and then the OnDisable of the first Subtitle Menu  which also run 12 times.

    It's a simple ActionList where it has 2 Dialogue : Play Speech actions (narration)
    and on my setup I have " Display Subtitles forever until user Skips"

    The button I use to skip is an AC.Button with Input Axis : SkipSpeech

    this is the code I have attached on my Unity UI Button. (Frame is the name of the Unity UI button which I want to deactivate on speeches.)

      private void OnEnable()
        {
            EventManager.OnMenuTurnOn += OnMenuTurnOn;
        EventManager.OnMenuTurnOff += OnMenuTurnOff;
        }
        private void OnDisable()
        {
            EventManager.OnMenuTurnOn -= OnMenuTurnOn;
        EventManager.OnMenuTurnOff -= OnMenuTurnOff;
        }

        void OnMenuTurnOn(AC.Menu menu, bool isInstant)
        {
            Debug.Log(menu.title);
            if (menu.title == "Subtitles" || menu.title == "Subtitles NPCs" || menu.title == "SubtitlesNarattion")
            {
                Frame.interactable = false;
                Debug.Log("button Deactivated");
            }
        }
        void OnMenuTurnOff(Menu menu, bool isInstant)
        {
            Debug.Log(menu.title);
            if (menu.title == "Subtitles" || menu.title == "Subtitles NPCs" || menu.title == "SubtitlesNarattion")
            {
                Frame.interactable = true;
                Debug.Log("button Activated");
            }
        }


    EDIT : After some research I found out that at PlayersMenu.cs the Line 1407 :     menu.TurnOff (true);
    runs all the time and when you click Skip on a dialogue it runs 12 times and triggers the OnDisable that many times and all these happens after the OnEnable of the next dialogue




    • when you add several Dialogue Play Speech actions in sequence on an ActionList, those actions work continuously?

    The "Play in background?" option in the Dialogue: Play speech Action determines whether they are run instantly or not.

    Have you checked Duplicate for each line? in the Subtitles menu's properties?  If not, does doing so make a difference?  That option causes each line to have its own instance of the menu.
  • edited May 2018
    Yes Duplicate for each line is checked, I can't use Play in Background because then it doesn't stop for the user to click to continue...  Can you check the turn off code at Line 1407 on PlayersMenu.cs? The problem is there. When you click next to continue to next dialogue it runs many times the menu.TurnOff (true); triggering the OnDisable several times after the OnEnable of the following Dialogue.


  • Also I tried the same thing by using the OnStartSpeech and OnStopSpeech. It does exactly the same thing. The OnDisable of the first dialogue runs several times after the OnEnable of the following dialogue
  • The repeated calling of the OnMenuTurnOff event is a bug and will be addressed, thanks for pointing it out.

    It won't, however, prevent OnMenuTurnOn from calling after OnMenuTurnOff if you are using duplicate menus.

    What you can try instead is to simply read whether or not any speech is actually playing at all:

    void Update ()
    {
      Frame.interactable = !AC.KickStarter.dialog.IsAnySpeechPlaying ();
    }

  • As for OnStartSpeech / OnStopSpeech - I'm not able to recreate that.  Only one event of each is called, and in the correct order.
  • Chris you are the best! About the OnStartSpeech / OnStopSpeech it was my fault I forgot to disable the OnMenuTurnOff and I thought it was doing the same problem.
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.