Response menu problem.

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Response menu problem.

Post by Japtor »

Hi,

Inside the Response Menu Panel, I can move from one response button to another with the Keyboard. All those buttons have available the Transition -> Color tint mode (Highlighted, etc) to know which one is "selected".

The problem is... When I start using the mouse, the button selected with the keyboard keeps highlighted/selected. It doesn't even disappear when the mouse is on another response button (which makes both buttons to be in highlighted mode).

Any idea?
Thanks.
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response menu problem.

Post by Tony Li »

That's the way Unity UI works. You can change the behavior by adding this script to your response button(s).

UIHighlightFix.cs

Code: Select all

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[RequireComponent(typeof(Selectable))]
public class UIHighlightFix : MonoBehaviour, IPointerEnterHandler, IDeselectHandler
{
    public void OnPointerEnter(PointerEventData eventData)
    {
        if (!EventSystem.current.alreadySelecting)
        {
            EventSystem.current.SetSelectedGameObject(this.gameObject);
        }
    }

    public void OnDeselect(BaseEventData eventData)
    {
        GetComponent<Selectable>().OnPointerExit(null);
    }
}
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Re: Response menu problem.

Post by Japtor »

Thanks! Seems to work! :)
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response menu problem.

Post by Tony Li »

I use it everywhere, not just for Dialogue System UIs. It's based on an old script that's been floating around the web for years. Unfortunately I don't remember who originally posted it, so I can't credit them.
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Re: Response menu problem.

Post by Japtor »

Another thing,

Is there a way to not lose the currently selected response button? If I click somewhere that is not the response button, the EventSystem switches to the first one, as inside the Standart UI Menu Panel -> Navigation -> First Selected I have assigned the first response button and inside UI Menu Panel -> Navigation -> Focus Check Frequency I have 0.2.

Thanks!
User avatar
Tony Li
Posts: 21684
Joined: Thu Jul 18, 2013 1:27 pm

Re: Response menu problem.

Post by Tony Li »

I'll add that in the next update. It will remember the most recently-selected button and re-select it instead of selecting the first one.
Japtor
Posts: 120
Joined: Thu Jun 28, 2018 1:41 pm

Re: Response menu problem.

Post by Japtor »

Thanks tony! :)
Post Reply