Horrors of OnPointerDown versus OnBeginDrag in Unity3D

后端 未结 2 1544
难免孤独
难免孤独 2020-12-09 00:58

I\'m concerned over the difference between OnPointerDown versus OnBeginDrag in single-finger movement code.

(In the latest Unity paradigm of

2条回答
  •  失恋的感觉
    2020-12-09 01:30

    The difference is that OnBeginDrag doesn't get called until the touch/mouse has moved a certain minimum distance, the drag threshold. You can set the drag threshold on the Event System component.

    This is necessary for when you have a hierarchy of objects with different ways of handling input, especially scrollviews. Imagine you have a scrollview with a vertical stack of cells, each with a button in it. When the touch first starts on one of the buttons, we don't know whether the user is tapping a button or dragging the scrollview. It isn't until the touch gets dragged for the drag threshold that we know it is a drag and not a tap.

提交回复
热议问题