Page 1 of 1

Response menu problem.

Posted: Wed Feb 20, 2019 12:54 pm
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.

Re: Response menu problem.

Posted: Wed Feb 20, 2019 1:04 pm
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);
    }
}

Re: Response menu problem.

Posted: Wed Feb 20, 2019 1:42 pm
by Japtor
Thanks! Seems to work! :)

Re: Response menu problem.

Posted: Wed Feb 20, 2019 1:47 pm
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.

Re: Response menu problem.

Posted: Wed Feb 20, 2019 2:53 pm
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!

Re: Response menu problem.

Posted: Wed Feb 20, 2019 3:01 pm
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.

Re: Response menu problem.

Posted: Wed Feb 20, 2019 3:32 pm
by Japtor
Thanks tony! :)