Author Topic: [SOLVED]UIDragScrollView remembering last scrollView on release with autofind  (Read 5747 times)

Genhain

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
  1. void FindScrollView ()
  2. {
  3.         // If the scroll view is on a parent, don't try to remember it (as we want it to be dynamic in case of re-parenting)
  4.         UIScrollView sv = NGUITools.FindInParents<UIScrollView>(mTrans);
  5.  
  6.         if (scrollView == null)
  7.         {
  8.                 scrollView = sv;
  9.                 mAutoFind = true;
  10.         }
  11.         else if (scrollView == sv)
  12.         {
  13.                 mAutoFind = true;
  14.         }
  15.         mScroll = scrollView;
  16. }
  17.  

so with this currently as is, if i drag from one scrollview to another, it will not reparent to the new scrollview...unless we either clear the reference or the previous scrollview get's destroyed or you press and release first where it will set the new scrollview anyway. Unless i am using UIDragscrollView & UIDragDropItem with scrollviews wrong? But i do not think so as this worked before i upgraded.
« Last Edit: November 04, 2014, 12:02:44 AM by Genhain »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragScrollView remembering last scrollView on release with autofind
« Reply #1 on: November 01, 2014, 05:12:52 AM »
The code in FindScrollView() will only run in OnEnable(), so unless you are enabling/disabling your content it won't execute. It's probably best to call it yourself in your OnDrop or wherever you're doing the reparenting.

droppedGameObject.BroadcastMessage("FindScrollView");

Genhain

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 38
    • View Profile
Re: UIDragScrollView remembering last scrollView on release with autofind
« Reply #2 on: November 02, 2014, 09:55:40 PM »
Yes and it has a UIDragDropItem script attached which disables UIDragScrollView on start and re-enables it on release. so FindScrollView was being called but once it got into FindScrollView there is checks for null and equality, but not if the current parent scrollview is different from the last, hence it just keeps the scrollview reference to it's previous parent. I am not sure if this is intended...but if not, here is how i fixed it.

  1. void FindScrollView ()
  2. {
  3.         // If the scroll view is on a parent, don't try to remember it (as we want it to be dynamic in case of re-parenting)
  4.         UIScrollView sv = NGUITools.FindInParents<UIScrollView>(mTrans);
  5.  
  6.                                            //-->EXTRA CHECK HERE<--
  7.         if (scrollView == null || ( mAutoFind && scrollView != sv ))
  8.         {
  9.                 scrollView = sv;
  10.                 mAutoFind = true;
  11.         }
  12.         else if (scrollView == sv)
  13.         {
  14.                 mAutoFind = true;
  15.         }
  16.         mScroll = scrollView;
  17. }
  18.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIDragScrollView remembering last scrollView on release with autofind
« Reply #3 on: November 03, 2014, 06:46:57 AM »
That makes sense, thanks.