Page 1 of 1
UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 7:34 am
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?
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 9:13 am
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.
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 5:16 pm
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!
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 5:51 pm
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.
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 5:54 pm
by enco
Yes, I assigned the same (and only) camera in the scene and even tried different sorting layers and orders. Didn't work.
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 7:38 pm
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.
Re: UI Builder: Responses not clickable
Posted: Fri Dec 29, 2023 8:40 pm
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;
}
}
Re: UI Builder: Responses not clickable
Posted: Sun Dec 31, 2023 9:50 am
by enco
Thank you, your provided code is working fine!
Re: UI Builder: Responses not clickable
Posted: Sun Dec 31, 2023 10:10 am
by Tony Li
Glad to help!