Home / Posts tagged "scrollrect"

Unity 4.6 UI and nested ScrollRect

I wanted to have nested ScrollRects with different scrolling axis using the new Unity UI 4.6. By default this cannot be achieved currently.

My goal was to be able to swipe through 4 pages of the main menu of my game (green axis) and then on one of the pages be able to swipe through a list of items (red axis):


So I created a subclass of ScrollRect that routes the drag events to all parent ScrollRects in case a simple rule checked in OnBeginDrag is true. For my simple case I just wanted to route events to the parent in case a horizontal drag was being initiated but the scroll rect is a vertical one, or a vertical drag was being initiated and the scroll rect is a horizontal one. This is my subclass: