Author Topic: BUG when using UIScrollBar with a simple UISprite foreground  (Read 1246 times)

Trepan

  • Guest
BUG when using UIScrollBar with a simple UISprite foreground
« on: November 01, 2013, 02:31:37 AM »
My project has a simple, clean art style, so the scrollbar I've set up uses a 'Simple' sprite type for its foreground element (to just show a solid rectangle). At the top and bottom of the scroll range all is good, but when anywhere in the middle the scroll bar's size switches to be a fixed square that bears no relationship to the UIDraggablePanel's content...  :(

I've dug into this and the problem appears to be related to this code inside ForceUpdate() of UIScrollbar:
  1.         mFG.width = Mathf.RoundToInt(fgs.x + fg.x + fg.z);
  2.         mFG.height = Mathf.RoundToInt(fgs.y + fg.y + fg.w);
  3.         if (val < 0.999f && val > 0.001f)
  4.         {
  5.                 mFG.MakePixelPerfect();                    // << Only called when not at top/bottom of range
  6.         }
  7.  

UISprite's MakePixelPerfect call is specifically testing for a Type.Simple and is effectively replacing the scrollbar's computed mFG.width/mFG.height values with the texture atlas dimensions of the sprite's image. I guess most people don't see this problem because they have fancier scrollbar's using Type.Sliced?

Not sure of the best fix. For now I just have the call to MakePixelPerfect commented out.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG when using UIScrollBar with a simple UISprite foreground
« Reply #1 on: November 01, 2013, 06:10:00 AM »
Better fix is to remove that code and just RoundToInt the position above. I've changed it on my end so you will see it in the next update.