I have a lot of buttons in a scroll view. All the buttons have onclick() actions, but I’m finding that unless I’m VERY careful and precise when tapping a button, I accidentally scroll the scrollview a very slight amount and the tap doesn’t register on the button. How can I work around this? For example, it would be nice if I could take action on “finger down” event for my buttons so it won’t matter whether my finger moves ever so slightly before I pick it up again.
Few options to try:
- Your scroll rect has a Scroll Sensitivity setting. Try adjusting that and see if it helps.
- Alternatively, you could try adding an
Event Trigger
component to the buttons and then “Add New Event Type” of “PointerDown”. That might give you your “finger down” event.
I solved this by implementing the IPointerDownHandler interface. This allows me to get notified of the touch start event for my buttons without stopping that event from bubbling-up to the enclosing scroll viewer, which is important because if the event doesn’t bubble up to that ancestor, then the scroll viewer won’t scroll by touch.
public class LevelButton : MonoBehaviour, IPointerDownHandler
...
...
...
public void OnPointerDown(PointerEventData eventData)
{
this.OnClick();
}