Forum rules - please read before posting.

Unity UI subtitles menu question

I'm redoing the subtitles menu in UI and I want it to pop-in/pop-out from the bottom, something like this > https://dl.dropboxusercontent.com/s/kff0zcny34j5ryd/2019-01-26_11-56-28.mp4

The animation is all done via script (mentioning because the custom Animation option tells to animate via Animator).
Can I use Event like OnStartSpeech and OnStopSpeech for calling the methods that animate the UI? Also, how will I call a component attached to the prefab?

Comments

  • If you're animating via script, then events are the way to go. However, the OnMenuTurnOn and OnMenuTurnOff events would likely be the most appropriate here. These provide the Menu class as a parameter, allowing you to extract its canvas, i.e.:

    using UnityEngine;
    using System.Collections;
    using AC;
    
    public class MenuEventTest : MonoBehaviour
    {
    
        private void OnEnable ()
        {
            EventManager.OnMenuTurnOn += OnMenuTurnOn;
        }
    
        private void OnDisable ()
        {
            EventManager.OnMenuTurnOn += OnMenuTurnOn;
        }
    
        private void OnMenuTurnOn (Menu menu)
        {
            if (menu.title == "Subtitles")
            {
                GameObject myUIGameObject = menu.canvas.gameObject;
            }
        }
    
    }
    
  • Thanks a lot Chris. Going to try this out now :)

  • So, I slight issue.

    When I switch ActionLists, the menu hides and shows. It creates a bit of weird affect where one subtitles menu is going down while other coming up. Is there a good way to circumvent that?

    One hack in my mind is to set a variable to true, ConverstionContinuining and not show the animation while the var is true. Is that the best way?

  • The speech menus will overlap naturally unless you insert a pause in between the speech Actions.

    You should be able to rely on events coupled with co-routines (to wait for X seconds) to time things correctly. I'm not clear on which animation you want to prevent, though - the ending of the first menu, or the beginning of the second - or both.

  • The ending of the first menu.

  • The OnMenuTurnOn event of the 2nd menu will kick in before the OnMenuTurnOff event of the 1st menu, which makes it a little tricky.

    What you could try is setting an internal bool, e.g. "IsTurningOn" to True inside OnMenuTurnOn, and setting it to False X seconds later (the duration of the "on" animation). If OnMenuTurnOff is called while IsTurningOn = True, ignore it.

  • Alright. Will do this

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.