Author Topic: 3.0.8 f7 - ScrollBar localPosition is NaN  (Read 3430 times)

doggan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
3.0.8 f7 - ScrollBar localPosition is NaN
« on: January 15, 2014, 12:51:03 AM »
I am getting the following error when clicking on a Scroll Bar whose contents are completely contained in a subpanel:
  1. transform.localPosition assign attempt for 'SubPanel' is not valid. Input localPosition is { 0.000000, NaN, 0.000000 }.
  2. UnityEngine.Transform:set_localPosition(Vector3)

I am able to repro it in the NGUI Example 9 - Quest Log scene.

Steps:
1). Open the Example 9 - Quest Log scene.
2). Find the "SubPanel" game object, and change it's UIScrollView show condition to "Always".
3). Press Play and enter game view.
4). Expand the top two quests so that the scroll bar foreground shrinks.
5). Collapse the two expanded quests so that the scroll bar foreground expands to full height.
6). Click on the scroll bar and try to drag and the error will occur.

Thanks.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.8 f7 - ScrollBar localPosition is NaN
« Reply #1 on: January 15, 2014, 10:06:38 PM »
Thanks, I will look into this when I return on the 16th.

drawmaster77

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: 3.0.8 f7 - ScrollBar localPosition is NaN
« Reply #2 on: January 20, 2014, 04:28:41 AM »
I am having the same issue, I just updated to 3.0.9.f2 and it's still happening.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: 3.0.8 f7 - ScrollBar localPosition is NaN
« Reply #3 on: January 20, 2014, 07:02:08 AM »
Thanks for the reminder. You can fix it by changing UIScrollBar.LocalToValue function to this one:
  1.         protected override float LocalToValue (Vector2 localPos)
  2.         {
  3.                 if (mFG != null)
  4.                 {
  5.                         float halfSize = Mathf.Clamp01(mSize) * 0.5f;
  6.                         float val0 = halfSize;
  7.                         float val1 = 1f - halfSize;
  8.                         Vector3[] corners = mFG.localCorners;
  9.  
  10.                         if (isHorizontal)
  11.                         {
  12.                                 val0 = Mathf.Lerp(corners[0].x, corners[2].x, val0);
  13.                                 val1 = Mathf.Lerp(corners[0].x, corners[2].x, val1);
  14.                                 float diff = (val1 - val0);
  15.                                 if (diff == 0f) return value;
  16.  
  17.                                 return isInverted ?
  18.                                         (val1 - localPos.x) / diff :
  19.                                         (localPos.x - val0) / diff;
  20.                         }
  21.                         else
  22.                         {
  23.                                 val0 = Mathf.Lerp(corners[0].y, corners[1].y, val0);
  24.                                 val1 = Mathf.Lerp(corners[3].y, corners[2].y, val1);
  25.                                 float diff = (val1 - val0);
  26.                                 if (diff == 0f) return value;
  27.  
  28.                                 return isInverted ?
  29.                                         (val1 - localPos.y) / diff :
  30.                                         (localPos.y - val0) / diff;
  31.                         }
  32.                 }
  33.                 return base.LocalToValue(localPos);
  34.         }

drawmaster77

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 21
    • View Profile
Re: 3.0.8 f7 - ScrollBar localPosition is NaN
« Reply #4 on: January 20, 2014, 05:19:27 PM »
thank you that fixed it.