Author Topic: a bug report of NGUI's ScrollView Component  (Read 3235 times)

rocman

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
a bug report of NGUI's ScrollView Component
« on: February 13, 2014, 01:22:06 AM »
Here's a bug report of NGUI's ScrollView Component.

If a scroll view is anchored, and if the anchoring makes the baseClipRegion of it changed, the contents in the scroll view will be wrongly positioned.

And here's my solution:

Since the bug happens in the case of baseClipRegion changing, it seems ok to fix it by calling the method "ResetPosition" which is to fix the position of the contents when baseClipRegion is changed.

So the following is the key code:

UIPanel.cs
public Vector4 baseClipRegion
{
   get
   {
      return mClipRange;
   }
   set
   {
      if (Mathf.Abs(mClipRange.x - value.x) > 0.001f ||
         Mathf.Abs(mClipRange.y - value.y) > 0.001f ||
         Mathf.Abs(mClipRange.z - value.z) > 0.001f ||
         Mathf.Abs(mClipRange.w - value.w) > 0.001f)
      {
         mResized = true;
         mCullTime = (mCullTime == 0f) ? 0.001f : RealTime.time + 0.15f;
------------------------------------------ before ------------------------------------------
         mClipRange = value;
------------------------------------------ after -------------------------------------------
         if (mClipRange != value)
         {
            mClipRange = value;
            var scrollViewComponent = this.GetComponent<UIScrollView>();
            if (scrollViewComponent != null)
            {
               scrollViewComponent.ResetPosition();
            }
         }
---------------------------------------------------------------------------------------------

         mMatrixFrame = -1;
#if UNITY_EDITOR
         if (!Application.isPlaying) UpdateDrawCalls();
#endif
      }
   }
}

Hopes this bug can be fixed at next version of NGUI, and so I don't have to member to change the code myself.
Looking forward to your replying.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: a bug report of NGUI's ScrollView Component
« Reply #1 on: February 13, 2014, 03:11:40 AM »
The fix you posted causes other problems, but I resolved it properly in 3.5.0 by adding a different function to call -- so you will find it fixed in the next update.

rocman

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: a bug report of NGUI's ScrollView Component
« Reply #2 on: February 13, 2014, 05:54:50 AM »
Big Thx to your quick response  :D