UI Builder: Responses not clickable

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
enco
Posts: 4
Joined: Fri Dec 29, 2023 7:31 am

UI Builder: Responses not clickable

Post by enco »

Hi,

I am using UI Builder for my general UI with a button that triggers a conversation, where the player should make a choice.

When the dialogue is started the responses appear, but are not clickable. If I disable the UI Builders UI it works.

Can I set some sort of render order, or how do I fix this?
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Builder: Responses not clickable

Post by Tony Li »

Hi,

Make sure your scene still has an active EventSystem GameObject. You may need to tick the input module component's Force Module Active checkbox. Keep an inspector view on the EventSystem during play so you can see what the mouse is detecting.

If that doesn't help, what input system are you using? Unity's built-in input manager, Input System package, Rewired, or something else?

Alternatively, you can build your dialogue UI in UI Toolkit (UI Builder) and write a script that implements the IDialogueUI C# interface. You can find a starter script in Plugins / Pixel Crushers / Dialogue System / Templates / Scripts / TemplateDialogueUI.cs. Since UI Toolkit is getting more stable and closer to feature parity with Unity UI, I'll be working on an official UI Toolkit implementation of IDialogueUI in the near future.
enco
Posts: 4
Joined: Fri Dec 29, 2023 7:31 am

Re: UI Builder: Responses not clickable

Post by enco »

I do have an active EventSystem Object in the Scene with a "Standalone Input Module", but there is no Checkbox "Force Module Active" and in the code it says this property is obsolete. I am using Unity 2022.3.10f1. I think I'm using the default built-in input manager. In the inspector view on the EventSystem the mouse is only detecting the response menu if the UI Toolkit UI is disabled.

It is working though when I set the Dialogue Manager canvas to Render Mode=Screen Space - Overlay instead of Camera. So for now this works, thanks for your help.

I am looking forward to your UI Toolkit implementation!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Builder: Responses not clickable

Post by Tony Li »

> t is working though when I set the Dialogue Manager canvas to Render Mode=Screen Space - Overlay instead of Camera.

When the Render Mode was set to Screen Space - Camera, did you assign a camera to the Canvas? Otherwise it won't pick up mouse input.
enco
Posts: 4
Joined: Fri Dec 29, 2023 7:31 am

Re: UI Builder: Responses not clickable

Post by enco »

Yes, I assigned the same (and only) camera in the scene and even tried different sorting layers and orders. Didn't work.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Builder: Responses not clickable

Post by Tony Li »

If you add another UI button to the Canvas that's outside of the dialogue UI, and if you can still click it (even if it does nothing), then this is probably a UI Toolkit issue, not a Dialogue System issue. You might want to bring it up on the UI Toolkit section of the Unity forum if that's the case.
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Builder: Responses not clickable

Post by Tony Li »

At runtime, UI Toolkit creates a child of the EventSystem GameObject named PanelSettings. This GameObject has a Panel Raycaster that intercepts mouse input, preventing Unity UI canvases from receiving mouse input.

One solution is to temporarily disable your UI Toolkit UIs' UI Document components. This will remove the PanelSettings GameObject until you re-enable the UI Documents.

Another option -- and probably the better option -- is to temporarily disable the Panel Raycaster during conversations. To do this, you can add this script to the Dialogue Manager:

DisablePanelRaycasterDuringConversations.cs

Code: Select all

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UIElements;

public class DisablePanelRaycasterDuringConversations : MonoBehaviour
{
    void OnConversationStart(Transform actor)
    {
        EventSystem.current.GetComponentInChildren<PanelRaycaster>().enabled = false;
    }
    void OnConversationEnd(Transform actor)
    {
        EventSystem.current.GetComponentInChildren<PanelRaycaster>().enabled = true;
    }
}
enco
Posts: 4
Joined: Fri Dec 29, 2023 7:31 am

Re: UI Builder: Responses not clickable

Post by enco »

Thank you, your provided code is working fine! :mrgreen:
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: UI Builder: Responses not clickable

Post by Tony Li »

Glad to help!
Post Reply