Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: rocman on February 13, 2014, 01:22:06 AM

Title: a bug report of NGUI's ScrollView Component
Post by: rocman 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.
Title: Re: a bug report of NGUI's ScrollView Component
Post by: ArenMook 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.
Title: Re: a bug report of NGUI's ScrollView Component
Post by: rocman on February 13, 2014, 05:54:50 AM
Big Thx to your quick response  :D