Animation when selecting from response menu

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Animation when selecting from response menu

Post 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?
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation when selecting from response menu

Post 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);
        }
nicmar
Posts: 133
Joined: Wed Aug 21, 2019 2:39 am

Re: Animation when selecting from response menu

Post 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?
Working on SpaceChef - A wacky open world space western, featuring a chef with nothing to loose, after he loses everything.. ;) Follow our work on @BlueGooGames.
User avatar
Tony Li
Posts: 22051
Joined: Thu Jul 18, 2013 1:27 pm

Re: Animation when selecting from response menu

Post 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);
}
Post Reply