Page 1 of 1

UI buttons getting selected by dialogue system

Posted: Tue Feb 22, 2022 10:20 am
by igorsandman
Hello,
I'm having an issue with dialogue system. It seems to be selecting a previously selected button on specific occasions.

If I open a menu from a dialogue sequence (for example, if I talk to a shop owner, he has a couple of lines of dialogue then I activate a gameobject that opens a menu to buy/sell), after a random amount of time of about half a second, the selected button on my menu gets deselected. It renders my menu unusable.

If I debug the currently selected gameobject, I notice something is selecting a previously selected button. If I setup a OnSelect function on that button and debug the source of the selection, it's dialogue system.

When I print on select from Yes Button I get this error:
Yes button Selected
UnityEngine.Debug:LogError(Object)
ConfirmationOnSelect:UnityEngine.EventSystems.ISelectHandler.OnSelect(BaseEventData) (at Assets/Scripts/Debug/ConfirmationOnSelect.cs:9)
UnityEngine.EventSystems.EventSystem:SetSelectedGameObject(GameObject)
PixelCrushers.UIPanel:OnDisable() (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIPanel.cs:190)
UnityEngine.GameObject:SetActive(Boolean)
PixelCrushers.UIPanel:OnHidden() (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIPanel.cs:251)
PixelCrushers.<WaitForAnimation>d__13:MoveNext() (at Assets/Plugins/Pixel Crushers/Common/Scripts/UI/UIAnimatorMonitor.cs:105)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
How can I avoid this?

Re: UI buttons getting selected by dialogue system

Posted: Tue Feb 22, 2022 10:47 am
by Tony Li
Hi,

There are two ways to avoid that:

1. When you open your menu on while the dialogue UI is still open, use this C# code to tell the dialogue UI to not retake selection focus:

Code: Select all

PixelCrushers.UIPanel.monitorSelection = false;
When you return to the dialogue UI, set it true again.

2. Or inspect the dialogue UI's subtitle panels and response menu panel. Set Focus Check Frequency to 0. This will prevent it from trying to retake focus entirely.

Re: UI buttons getting selected by dialogue system

Posted: Tue Feb 22, 2022 11:17 am
by igorsandman
Hi,
I tried both methods but none of them worked.
I also unticked "select previous on disable" but it didn't help either.

Re: UI buttons getting selected by dialogue system

Posted: Tue Feb 22, 2022 11:33 am
by Tony Li
Hi,

Can you try backing up your project and updating to the latest Dialogue System version?

If you can't do that, try backing up your project and importing only UIPanel.cs from the latest version.

Re: UI buttons getting selected by dialogue system

Posted: Wed Feb 23, 2022 3:49 am
by igorsandman
Hi,
I updated to the latest version. The problem still persists.

Re: UI buttons getting selected by dialogue system

Posted: Wed Feb 23, 2022 9:42 am
by Tony Li
Here's an example scene exported from Unity 2021.2:

DS_TestMonitorSelection_2022-02-23.unitypackage

Can you compare your setup to this one?

Or, if you prefer, feel free to send a reproduction project to tony (at) pixelcrushers.com

Re: UI buttons getting selected by dialogue system

Posted: Wed Feb 23, 2022 9:55 am
by igorsandman
I have sent you a reproduction project.
Thank you.

Re: UI buttons getting selected by dialogue system

Posted: Wed Feb 23, 2022 1:36 pm
by Tony Li
Hi,

Dialogue UIs are very persistent about re-selecting the previous selection when closing. To turn that off, you'll need to untick Select Previous On Disable on all of these GameObjects:
  • Basic Standard Dialogue UI > Dialogue Panel
  • Basic Standard Dialogue UI > NPC Subtitle Panel
  • Basic Standard Dialogue UI > NPC Subtitle Panel
  • Basic Standard Dialogue UI > Response Menu Panel
  • Shop's Bubble Modified
I think the checkbox on the Dialogue Panel really doesn't need to be ticked in the version of the prefab that ships with the Dialogue System. It will be unticked in the next release.

Re: UI buttons getting selected by dialogue system

Posted: Thu Feb 24, 2022 7:46 am
by igorsandman
Thank you Tony,
I didn't realize I needed to update those options for the basic standard prefab since I'm using a custom Bubble.
It works now.
Thanks!

Re: UI buttons getting selected by dialogue system

Posted: Thu Feb 24, 2022 8:50 am
by Tony Li
Glad to help! In this case, the Dialogue Manager still activates the Basic Standard Dialogue UI's Dialogue Panel so it's ready to use any of the basic subtitle/menu panels in case any conversation participants don't have bubble panels. The Dialogue Panel is the one that was restoring the previous selection. This shouldn't be an issue in version 2.2.26+ since I'm going to untick Select Previous On Disable on the Dialogue Panel in the prefabs.