I’m looking to solve this Nested ScrollRect issue by handling some of the EventSystem calls. However, whenever I pass a drag event from a child scroll rect to a parent scroll rect, it uses the last selected position as it’s starting point instead of the cursor’s current position.
Here is the code that isn’t giving me the behavior I’m looking for:
public void OnDrag (PointerEventData data) {
if (Mathf.Abs (data.delta.y) > 3)
data.pointerDrag = parentScrollRect;
}
The goal there is to only pass drag control to the parent when they aren’t scrolling horizontally anymore. This works, but everytime the parent takes over, it snaps to the last location the parent began it’s scrolling from. Very confusing, I feel there needs to be a different approach to accomplish Nested Scrollrects.
Is there a way to force a drag event to stop and begin a new one without the user lifting their finger at all? At that point I could toggle raycasts at the right time to ignore the child ScrollRects.
This is a fairly elaborate situation so if this isn’t enough info I can provide more towards the problem.
Edit: A cheap workaround solution in the next post…
Edit2: What I feel Unity needs to do for ScrollRects, or DragHandlers in general, is add New Event Handlers based on Drag Axis, This way when you uncheck a ScrollRect to only scroll on one axis it doesn’t soak up all the dragging ignoring everything else behind it, even though the axis is disabled for that ScrollRect. Also the option of temporarily ignoring a handler mid-drag would be good.