Page 1 of 1

Animation when selecting from response menu

Posted: Wed Feb 03, 2021 4:33 pm
by nicmar
As you might have noticed, I'm making animations with DoTween when opening and closing subtitles.
However I've stumbled upon the issue that when I select a response from a StandardUIMenuPanel (which now I use as CustomUIMenuPanel as a subclass), the HideResponses() call is run, then the gameobject is disabled.

I tried overriding HideResponses() to play my animation, then use base.HideResponses(), but it still closes the window.

So I suspect something else higher up in the system closes it. Do you know what that could be and have a possible solution for me?

Re: Animation when selecting from response menu

Posted: Wed Feb 03, 2021 4:53 pm
by Tony Li
Make a subclass of StandardDialogueUI (if you haven't already). Override ShowSubtitle. The original method is:

Code: Select all

        public override void ShowSubtitle(Subtitle subtitle)
        {
            conversationUIElements.standardMenuControls.Close();
            conversationUIElements.standardSubtitleControls.ShowSubtitle(subtitle);
        }
The first thing it does when showing a subtitle is to tell all menu panels to close, in case they aren't already closed. If you know the menu panel will be closed, in your version you can get rid of that line:

Code: Select all

        public override void ShowSubtitle(Subtitle subtitle)
        {
            conversationUIElements.standardSubtitleControls.ShowSubtitle(subtitle);
        }

Re: Animation when selecting from response menu

Posted: Thu Feb 04, 2021 5:05 am
by nicmar
Great, it almost worked!
My animation plays, but it starts showing the next subtitle right away.
Where do I intervene with that, so I can manually advance to the next subtitle when my animation has finished playing?

Re: Animation when selecting from response menu

Posted: Thu Feb 04, 2021 9:55 am
by Tony Li
In the same overridden ShowSubtitle, start a coroutine. Maybe something like:

Code: Select all

public override void ShowSubtitle(Subtitle subtitle)
{
    StartCoroutine(ShowSubtitleAfterMenuCloses(subtitle));
}

IEnumerator ShowSubtitleAfterMenuCloses(Subtitle subtitle)
{
    float timeout = Time.time + 5f; // Time out after 5 seconds in case menu never closes for some reason.
    // NOTE: You may need to change the while() condition below for your needs:
    while (conversationUIElements.defaultMenuPanel.isOpen && Time.time < timeout)
    {
        yield return null;
    }
    conversationUIElements.standardSubtitleControls.ShowSubtitle(subtitle);
}