Author Topic: UITexture Auto-Add Pixel Behavior  (Read 4273 times)

kromenak

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
UITexture Auto-Add Pixel Behavior
« on: January 08, 2014, 12:33:39 AM »
I happened upon that feature of UITextures where it will automatically add an additional pixel to non-even textures.  I gather this is useful for centering odd-pixel widgets, but it was a bit surprising to encounter in other contexts. 

For example, I have a need to display a 9x9 pixel UITexture that essentially fits into a picture frame UI very snugly.  It was surprising after upgrading to NGUI 3.x that it didn't fit correctly and had an unexpected extra gap around the edges - had to do some digging to discover why it was occurring, but it seemed like a bug at first.

For now, I've got to comment out those lines in UITexture, but my feedback would be having some sort of way to toggle whether you want to use that "extra pixel" functionality in the future or not.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UITexture Auto-Add Pixel Behavior
« Reply #1 on: January 08, 2014, 12:50:52 PM »
When a widget is centered, it's necessary to make dimensions even. 9 / 2 = 4.5, meaning it will either be blurry, or have 4 pixels on one side and 5 pixels on another = not centered. You could always use a bottom-left pivot instead and the extra pixel of padding won't cause any issues.