4.6 Scroll Rect not working with Event Triggers?

Hi all,
I’ve setup a Scroll Rect to scroll a Toggle Group with a bunch of Toggles. If I use the OnValueChange event in the Toggle component the scrolling works perfectly. Instead, if I want come more complex logics and I use an Event Trigger component (to get Select, Deselect and other events) these seem to absorb the touch event breaking the scrolling functionality.

Is someone else having this issue? Do you know what may cause it and a workaround?

Thank you all.

How to reproduce the problem step by step

  1. Create a new scene
  2. Create a UI Canvas
  3. Create a UI Panel, call it “Scroller” and make it child of your canvas
  4. Create another UI Panel, bigger than the previous one, and make it child of the previous panel, call it “Content” and make sure it is assigned an image.
  5. Create a new game object and add a Toggle Group component to it. Call it toggle group and make it child of you “Content” panel.
  6. Create one or two Toggles, add some graphics to them (image or text) and make them children of “Content”
  7. Test the scrolling. It should work even when you start dragging from one of the toggles.
  8. Now add an Event Trigger component to your triggers, add a couple of event types (Select and Deselect will do).
  9. Test again. Now it shouldn’t work when starting to drag from any toggles.

Hello,

Check these interfaces :

You can achieve this by adding to your GameObjects a Monobehaviour which implements every one of those.

Had the same issue right now. Found this solution and it works perfectly for me:

Fairly old question but ran into somewhat same situation with Unity 5.3.3. Easy way to fix is put your eventtrigger on the scroll rect instead of the object you want to cause the trigger, the scroll rect triggered it for me.

Can be fixed using this OnDeselect

a work around would be to use a button component and then add the triggers to that button using the already supplied “On ClicK” trigger of the button itself rather than using standalone event trigger components. it is strange but it works

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class SlotBtn : EventTrigger {
public override void OnBeginDrag( PointerEventData PED )
{
transform.GetComponentInParent().OnBeginDrag( PED );
}
public override void OnDraw ( PointerEventData PED )
{
transform.GetComponentInParent().OnDrag( PED );
}
public override void OnEndDrag( PointerEventData PED )
{
transform.GetComponentInParent().OnEndDrag( PED );
}
public override void OnPointerDown (PointerEventData PED )
{
// here on Click Event.
}
}

http://blog.naver.com/nameisljk/220766219004

:slight_smile: