A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate
in the Unity community.
Discussion in 'UGUI & TextMesh Pro' started by ssawyer, Sep 15, 2014.
I just wanted to express my deepest gratitude to @CaptainSchnittchen
I got worried that can I implement this script into my project... HAHA! Easy and super-good! Thank you @CaptainSchnittchen
Please, help me.
If I have something like this, where should I put this script and how can I configure it?
Placing the script on page 2 or its content does not work.
Are you using the script from @CaptainSchnittchen ?
Hi. Yes, script from CaptainSchnittchen.
You need only create new ScrollViews as children of your Default ScrollView, but on the children, you need to use the ScrollRectEx script (instead of the default ScrollRect script) because it will route the drag events to parent.
In this example, the Parent has only Vertical movement while every child has only Horizontal movement:
Thank you very much! Everything worked out!
Here's a version not creating all those anonymous functions but using the ExecuteEvents API provided by Unity.
To me it seems to be the more "correct" way of implementing events propagating upwards. Also it may be more GC-friendly.
public class ScrollRectEx : ScrollRect
private bool routeToParent = false;
/// Always route initialize potential drag event to parents
public override void OnInitializePotentialDrag(PointerEventData eventData)
ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.initializePotentialDrag);
/// Drag event
public override void OnDrag(UnityEngine.EventSystems.PointerEventData eventData)
ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.dragHandler);
/// Begin drag event
public override void OnBeginDrag(UnityEngine.EventSystems.PointerEventData eventData)
if (!horizontal && Math.Abs(eventData.delta.x) > Math.Abs(eventData.delta.y))
routeToParent = true;
else if (!vertical && Math.Abs(eventData.delta.x) < Math.Abs(eventData.delta.y))
routeToParent = true;
routeToParent = false;
ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.beginDragHandler);
/// End drag event
public override void OnEndDrag(UnityEngine.EventSystems.PointerEventData eventData)
ExecuteEvents.ExecuteHierarchy(transform.parent.gameObject, eventData, ExecuteEvents.endDragHandler);
routeToParent = false;
Thank You Very Much @CaptainSchnittchen , you are a gem
Thank You @CaptainSchnittchen you are a genius.
I don't know how to thank you.
Can not Thank you enough.
Thank you very much @CaptainSchnittchen , you are a genius
your code still awesome. Even in 2k19! Thanks!
@CaptainSchnittchen thank you very much, this is genious. Saved me a lot of time.
Thanks from me too, @CaptainSchnittchen!!! Great solution.
Can you tell me how to do that plz
I used this one and it worked perfectly for me:
First of all, thank you for creating this post. With the script of @cp- which is inspired by @CaptainSchnittchen. I manage to create nested scroll rect. I am attaching the Image and video so that others can achieve something like this if they want to.
Asset use:- simple scroll (Free from asset Store) + Above scroll Rect Ex Script + Dotween(Free from asset Store).
Thank you really, you saved my life
@KGC Thanks a ton!
@CaptainSchnittchen THANKS A LOT
@CaptainSchnittchen Thank you so much! (I'm not late, am I?)
@CaptainSchnittchen even 2020 is coming, that's nice solution. Thankyou very much and Merry Christmas!
Thank you so much! this solved the problem instantly!
Thank you very much, @CaptainSchnittchen
@cp- and @CaptainSchnittchen , thank you guys!
Five years on... still awesome! Copied the code and it worked like a charm. You rock @CaptainSchnittchen.
Although I had an even more complicated sructure, where I had scrollrect->scrollrect->scrollrect so had to intercept your while loop and break it where I wanted. But this was sleek!!
FYI, ScrollRectEx and also the ScrollRectConflictManager have been part of the awesome Unity UI Extensions project (link in sig) for a long time. We recently had another big release for 2019 that's work checking out.
Although seeing some other interesting proposed updates, so I'm going to have to review and see what if anything can be improved.
This is working like a charm, try it!