UI buttons getting selected by dialogue system

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

UI buttons getting selected by dialogue system

Post 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?
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI buttons getting selected by dialogue system

Post 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.
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: UI buttons getting selected by dialogue system

Post 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.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI buttons getting selected by dialogue system

Post 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.
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: UI buttons getting selected by dialogue system

Post by igorsandman »

Hi,
I updated to the latest version. The problem still persists.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI buttons getting selected by dialogue system

Post 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
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: UI buttons getting selected by dialogue system

Post by igorsandman »

I have sent you a reproduction project.
Thank you.
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI buttons getting selected by dialogue system

Post 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.
igorsandman
Posts: 35
Joined: Fri Jul 09, 2021 9:50 am

Re: UI buttons getting selected by dialogue system

Post 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!
User avatar
Tony Li
Posts: 21981
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI buttons getting selected by dialogue system

Post 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.
Post Reply