Subtitle Panel Yield To Menu Panel

Announcements, support questions, and discussion for the Dialogue System.
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle Panel Yield To Menu Panel

Post by Tony Li »

The Standard Dialogue UI's new Wait For Close checkbox waits for subtitle and menu panels to close. Then it allows the Standard Dialogue UI's Dialogue Panel to close.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Subtitle Panel Yield To Menu Panel

Post by VoodooDetective »

Ahh so it is "Wait for Close to Close." Ok great, that's exactly what I need for the Dialogue Panel! Thanks for clarifying that!
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle Panel Yield To Menu Panel

Post by Tony Li »

I'll add that to the hover tooltip to make it clear what it does.
jjpixelc
Posts: 44
Joined: Sun Mar 01, 2020 1:04 pm

Re: Subtitle Panel Yield To Menu Panel

Post by jjpixelc »

Tony Li wrote: Thu Jan 07, 2021 8:38 am What version of the Dialogue System are you on? The most recent version has additional Wait For Close checkboxes on subtitle panels. And the upcoming version 2.2.15 has a Wait For Close checkbox on the Standard Dialogue UI component itself that waits for all subtitle panels and menu panels to close before closing itself. Would that address your needs?
Sorry to jump in here :-)
I am running version 2.2.14 and I don't see any "Wait For Close" checkboxes on my Standard UI Subtitle Panel scripts.
Am I missing something?
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle Panel Yield To Menu Panel

Post by Tony Li »

It's tucked away near the bottom of the inspector:

waitForClose.png
waitForClose.png (20.01 KiB) Viewed 1900 times
jjpixelc
Posts: 44
Joined: Sun Mar 01, 2020 1:04 pm

Re: Subtitle Panel Yield To Menu Panel

Post by jjpixelc »

It wasn't there on my panel.
But I solved the issue now.
It seems Unity has a problem with updating asset packages right now - or at least mine has.
Both my AC and DS assets reported fully updated to latest version, but in reality they weren't.
I just deleted the assets from the cahce folder and re-downloaded and reimported.
Now everything is fine - the panel is updated with the new wait for close setting.

If this is a general Unity problem, I imagine it could be quite a headache for you asset publishers :-)
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle Panel Yield To Menu Panel

Post by Tony Li »

It is. Unity's Package Manager window is broken. The Asset Store team says it's their top priority right now. But unfortunately it's been quite a while since it's been broken.

If you're using Unity 2019.4 or earlier, you can use the Asset Store window. Otherwise, if you're using 2020.x, deleting the old version out of the cache, as you did, is the only solution.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Subtitle Panel Yield To Menu Panel

Post by VoodooDetective »

Sorry to resurrect an old thread (and two bug you twice in one day), but I updated to 2.2.18 today and noticed that "Wait for Close" definitely now exists on StandardDialogueUI, but the problem I was running into actually had to do with the Dialogue Panel, not the Basic Standard Dialogue UI.

The Dialogue Panel has a UIPanel script on it, and you can select to have it Deactivate on Hidden. Because this panel doesn't wait for other panels to close before deactivating, it cuts all the closing panels off before they can finish closing.

I've still got my workaround in place:

Code: Select all

using System.Collections;
using PixelCrushers.DialogueSystem;
using UnityEngine;

namespace PixelCrushers
{
    public class VoodooDetectiveDialoguePanel : UIPanel
    {
        // Properties
        private Coroutine routine;

        public override void Open()
        {
            // Stop trying to close if we got a request to open
            if (routine != null) StopCoroutine(routine);
            base.Open();
        }

        public override void Close()
        {
            // Wait for sub-panels to close before closing
            // TODO: wait to see how this resolves: https://www.pixelcrushers.com/phpbb/viewtopic.php?f=3&t=3917&p=21721#p21721
            routine = StartCoroutine(CloseRoutine(base.Close));
        }

        private IEnumerator CloseRoutine(System.Action closeLambda)
        {
            float safeguardTime = Time.realtimeSinceStartup + 8f;
            while (AreAnyPanels(UIPanel.PanelState.Closing) && Time.realtimeSinceStartup < safeguardTime)
            {
                yield return null;
            }
            closeLambda?.Invoke();
        }

        private bool AreAnyPanels(params UIPanel.PanelState[] panelStates)
        {
            StandardDialogueUI dialogueUI = ((StandardDialogueUI)DialogueManager.instance.dialogueUI);
            StandardUIDialogueControls dialogueControls = (StandardUIDialogueControls)dialogueUI.dialogueControls;
            foreach (var panel in dialogueControls.subtitlePanels)
            {
                if (panel != null)
                {
                    foreach (UIPanel.PanelState state in panelStates)
                    {
                        if (panel.panelState == state) return true;
                    }
                }
            }
            foreach (var panel in dialogueControls.menuPanels)
            {
                foreach (UIPanel.PanelState state in panelStates)
                {
                    if (panel.panelState == state) return true;
                }
            }
            return false;
        }
    }
}


But I was wondering if this was something that could be added to UI Panel? Or maybe I'm doing something wrong? Sorry again for bugging you again!
User avatar
Tony Li
Posts: 21987
Joined: Thu Jul 18, 2013 1:27 pm

Re: Subtitle Panel Yield To Menu Panel

Post by Tony Li »

Hi,

The main dialogue UI GameObject itself has a Standard Dialogue UI component. This component has a Conversation UI Elements > Wait For Close checkbox. If you tick that, it should wait for all subtitle panels and menu panels to close before closing the Dialogue Panel.
VoodooDetective
Posts: 222
Joined: Wed Jan 22, 2020 10:48 pm

Re: Subtitle Panel Yield To Menu Panel

Post by VoodooDetective »

Ah so that's the top level Game Object. I'm referring to the Dialogue Panel. I've attached an image so you can see which Game Object i'm talking about. It has a UIPanel script on in, not the StandardDialogueUI which is on the "Voodoo Detective Dialgoue UI" Game Object.

That Dialogue Panel UIPanel doesn't have "Wait for Close" on it.
Attachments
Screen Shot 2021-07-27 at 11.03.33 AM.png
Screen Shot 2021-07-27 at 11.03.33 AM.png (24.61 KiB) Viewed 1835 times
Post Reply