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

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

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

Post 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
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

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

Post 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();
    }
}
User avatar
Abelius
Posts: 318
Joined: Fri Jul 21, 2017 12:45 pm

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

Post 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!
Unity 2019.4.9f1
Dialogue System 2.2.15
User avatar
Tony Li
Posts: 22061
Joined: Thu Jul 18, 2013 1:27 pm

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

Post by Tony Li »

Glad to help! :-)
Post Reply