and if there is no UIScrollView in parents, the UIDragScrollView script resets scrollView paremeter to null. in this line of UIDragScrollView.Press function:
can you fix it and add scrollView!= null in this condition?
if (!pressed && mAutoFind && scrollView!= null) scrollView = NGUITools.FindInParents<UIScrollView>(mTrans);
Title: Re: UIDragScrollView resets scrollView
Post by: ArenMook on December 03, 2013, 06:30:28 PM
Thanks, try the attached script.
Title: Re: UIDragScrollView resets scrollView
Post by: zazery on December 03, 2013, 07:11:28 PM
Those changes also fixed the problem I encountered yesterday where scrollView wasn't set when adding a child using NGUITools.AddChild.
Title: Re: UIDragScrollView resets scrollView
Post by: ComicSans on January 14, 2014, 04:02:56 PM
I found another small bug in UIDragScrollView. NGUI version 3.0.8f7
When UIDragScrollView is first enabled and has no scrollView, mAutoFind is set to true. If you then manually set scrollView and UIDragScrollView goes through another disable/enable cycle before being pressed, mAutoFind remains set to true at the end of FindScrollView, even though the auto-found view does not match the manual view.
I fixed this in my copy by adding a final else clause to the branches in FindScrollView, setting mAutoFind to false.
Have a good day!
Title: Re: UIDragScrollView resets scrollView
Post by: ArenMook on January 14, 2014, 09:15:39 PM
Thanks, but if you can remind me about this after the 16th, I'd much appreciate it.
Title: Re: UIDragScrollView resets scrollView
Post by: Isamson on January 28, 2014, 05:48:31 PM
Bump in case you've forgotten about this :)
Title: Re: UIDragScrollView resets scrollView
Post by: ArenMook on January 29, 2014, 10:05:57 AM
I think a more appropriate fix for this would be to only call FindScrollView() if 'mScroll' is null in OnEnable:
if(mAutoFind || mScroll ==null) FindScrollView();
Title: Re: UIDragScrollView resets scrollView
Post by: renanse on March 25, 2014, 02:57:08 PM
Sorry for a little necro'ing, but just in case other folks hit this issue, I'm finding that even with your patch above I don't get the desired behavior in at least one case. I have a draggable panel I am adding via code as a sibling GameObject of the GameObject holding my scroll view. When I add a new draggable area via code (eg, something like this:)
OnEnable is called as soon as I call AddComponent - before the assignment of scrollView. Thus, FindScrollView enters the if (scrollView == null) and sets mAutoFind to true. I worked around that issue by setting the GameObject to inactive before adding the component: