Author Topic: Accordion SV repopulation not detecting OnDrag  (Read 1754 times)

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Accordion SV repopulation not detecting OnDrag
« on: June 23, 2014, 01:29:21 AM »
I'm using the accordion SV together with PoolManager.  Each accordion Item is a prefab.  When the accordion is populated the first 2 times, everything works fine.  Upon the third time clearing and repopulating the accordion, I cannot drag the items in the horizontal SV.

When I expand one of the Accordion Item header, the items in the horizontal SV are all there, but when I try to drag, I cannot.  After clicking a few times, then the dragging works.

In the SV, I added a debug.log and found that it's showing:

SV: OnDrag =Scroll View, mShouldMove =False, active =False

After trying to drag a few time, then it turns into:
SV: OnDrag =Scroll View, mShouldMove =True, active =True

I tried using NGUITools make the SV active but still doesn't work.

Edit:  I used this debug line:

Debug.Log("SV: OnDrag ="+ transform.name + ", mShouldMove ="+ mShouldMove + ", NGUIactive ="+ NGUITools.GetActive(gameObject)+ ", active ="+ gameObject.activeSelf);

Got:


SV: OnDrag =Scroll View, mShouldMove =False, NGUIactive =False, active =True

As a test, I made mShouldMove into a public and explicitly set it to True before attempting to drag.  Still, when I try to drag mShouldMove is False.


« Last Edit: June 23, 2014, 01:51:35 AM by wallabie »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Accordion SV repopulation not detecting OnDrag
« Reply #1 on: June 24, 2014, 02:32:18 AM »
"should move" check will be 'false' if the content of the scroll view fits into it. The idea is that it doesn't make much sense to drag something if it already fits, although it makes the assumption that the scroll view's content is in its original position. You can see this being like that in the Quest Log example where it's not possible to drag the scroll view until you expand a pair of items.

wallabie

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 200
    • View Profile
Re: Accordion SV repopulation not detecting OnDrag
« Reply #2 on: June 24, 2014, 05:21:17 AM »
Please read the posting.

This has nothing to do with the "content of the scroll view fits into it."

Everything works as expected the first 2 times.  On the third time, the dragging stops working. 
What I pointed about the mShouldMove is the problem. 




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Accordion SV repopulation not detecting OnDrag
« Reply #3 on: June 25, 2014, 04:51:51 AM »
I understand, but "mShouldMove" is set in OnPress using the 'shouldMove' virtual property (which you can override btw), which checks for the bounds of the content against that of the scroll view's region. Since "mCalculatedBounds" is set to 'false' right above the 'shouldMove' check, then this also means that the bounds get re-calculated right then and there too. So from the code's point of view, the only way 'shouldMove' would be false now is if the content actually already fits into the scroll view and "disable dragging if fits" is checked.

P.S. Why is the game object inactive in the hierarchy in your debug log output? Scrolling won't work if the object is disabled.