Author Topic: Scrollview/grid issue with 3.6.9  (Read 4354 times)

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Scrollview/grid issue with 3.6.9
« on: August 10, 2014, 09:06:22 PM »
Hello,

I was on 3.6.4 and just grabbed 3.6.9. I have a scroll view which has a grid child. Previously, I set it up so that when you swipe, the grid items (book pages) slide to the next page and snap into place. I'm using the UI Center On Child script attached to my grid.

Anyways, now the center on child script is not working. When I swipe the pages to the right, it slides and then just stops where ever.

Do you know what is causing this and how I can fix it?

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview/grid issue with 3.6.9
« Reply #1 on: August 12, 2014, 12:00:59 AM »
UIWrapContent itself hasn't changed much, but UIScroll View did have some alterations. UIScrollView.Scroll was this before:
  1.         public void Scroll (float delta)
  2.         {
  3.                 if (enabled && NGUITools.GetActive(gameObject) && scrollWheelFactor != 0f)
  4.                 {
  5.                         DisableSpring();
  6.                         mShouldMove = shouldMove;
  7.                         if (Mathf.Sign(mScroll) != Mathf.Sign(delta)) mScroll = 0f;
  8.                         mScroll += delta * scrollWheelFactor;
  9.                 }
  10.         }
...and UIScrollView's LateUpdate section around line 948 was this:
  1. // Restrict the contents to be within the scroll view's bounds
  2.                                 if (restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
  3.                                         RestrictWithinBounds(false, canMoveHorizontally, canMoveVertically);
(now it's a somewhat longer "if" statement).

Try replacing the code as such and let me know which one helps.

DevMan5000

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: Scrollview/grid issue with 3.6.9
« Reply #2 on: August 30, 2014, 03:26:28 PM »
Alright, I spent an hour looking at this.

I ran the scroll view example scene which has a center on child. That worked so, the NGUI code is operational.

I made a bare bones scene to emulate the example and see where the issue lied.

Long story short, the Center On Child Component doesn't appear initially active when the game runs, despite showing a checked state in the property inspector. When I unchecked it and then re-checked it, then the Center On Child functionality started working.

So previously in NGUI 3.6.4, the component must have been active from the get go, but something must have changed in between then an 3.6.9 to make it start as inactive.

A work around would be for me to activate it myself on startup, but I am assuming that you will put in a fix for this?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview/grid issue with 3.6.9
« Reply #3 on: August 31, 2014, 02:55:15 PM »
Have you tried it in the last version? I'm pretty sure I already have...