IScrollHandler doesn't respond

Hi,
I am trying to use OnScroll but OnScroll is not being called by the Event System. A ScrollRect is attached to the gameObject and main functions of ScrollRect is working fine at runtime. Here is the code:

using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class scrollevents : MonoBehaviour, IScrollHandler
{


    public void OnScroll(PointerEventData data)
    {
      print(data.scrollDelta);
    }


}

Am I missing something?
Thanks

It seems to be working here with my mouse / setup.

Allright,
As I understand, the OnScroll is for mouse wheel move, not for mouseclick-scroll. OnDrag is working for that.
Thanks

1 Like

And just to clarify, you don’t need a ScrollRect to be able to use OnDrag or OnScroll, an Image or some other Graphic subclass is enough. Someone had created a NonDrawingGraphic that avoids extra draw calls if you don’t need an image for anything: UI panel without Image component as Raycast target? It is possible? - Questions & Answers - Unity Discussions.

1 Like