Page 1 of 1

Mouse wheel scroll doesn't work with Unity UI Color Text

Posted: Tue Dec 26, 2017 8:43 pm
by Abelius
Hi,

I'm in the process of customizing a Dialogue UI for a new project. I've used the generic one as a template, so I've been able to use the mouse wheel to scroll the Response Panel contents.

That functionality has stopped working when I've added a Unity UI Color Text script and an Event Trigger script components to the button template, to highlight each response when hovering them.

I still can scroll the responses if I use the scrollbar handler, but not the mouse wheel. Or to be more accurate, if I'm hovering a response then I can't use the mouse wheel to scroll them. I need to move the mouse pointer outside (but still inside the Response Panel) them so it works.

I'd very much like to tint the responses when hovering them, but also being able to scroll the responses with the mouse wheel, which is the most intuitive way to do it, ofc.

What could I do in this case?

I have Unity 2017.1.2p4 and Dialogue System 1.7.6.


Some screenshots...:

Image

Image

Image

Image

Image

Re: Mouse wheel scroll doesn't work with Unity UI Color Text

Posted: Tue Dec 26, 2017 10:27 pm
by Tony Li
Hi,

The Event Trigger script consumes events so the regular Unity UI handlers (e.g., scrolling) never receive them.

Instead of using Event Trigger, add a script like the one below. It provides UnityEvents for OnPointerEnter and OnPointerExit without consuming the events.

OnPointerEnterExit.cs

Code: Select all

using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

public class OnPointerEnterExit : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    public UnityEvent onPointerEnter = new UnityEvent();
    public UnityEvent onPointerExit = new UnityEvent();

    public void OnPointerEnter(PointerEventData eventData)
    {
        onPointerEnter.Invoke();
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        onPointerExit.Invoke();
    }
}

Re: Mouse wheel scroll doesn't work with Unity UI Color Text

Posted: Wed Dec 27, 2017 6:00 am
by Abelius
Oooh, so it's actually a Unity issue! And here I was asking your help as if it was a problem on your plugin's side... :oops:

But you helped me all the same... What can I say? You rock, as always. :D

Thanks!

Re: Mouse wheel scroll doesn't work with Unity UI Color Text

Posted: Wed Dec 27, 2017 8:18 am
by Tony Li
Glad to help! :-)