Author Topic: Atlas pixel size and sprite padding  (Read 2257 times)

Philipp_S

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 2
    • View Profile
Atlas pixel size and sprite padding
« on: February 17, 2015, 11:47:20 AM »
Hi!

We're using reference atlases to adjust our UI for SD and retina displays. The HD atlas has a pixel size of 0.5. In theory, we'd expect that switching everything to HD would just require us to switch out the atlas that the reference atlas points to - but as many of our sprites have padding, everything looks wonky when we switch to HD.

The way I see it, our problem is that a sprite's padding doesn't take the atlas' pixel size into account (whereas its border does that). Is this intended behaviour? Changing the UISprite class to multiply paddings by pixelSize fixes our problem, but I'd rather know if I'm missing something obvious, before I make changes that break with every NGUI update.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas pixel size and sprite padding
« Reply #1 on: February 17, 2015, 09:48:22 PM »
I think that would make sense... can you post the exact changes you had to make?

Philipp_S

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 2
    • View Profile
Re: Atlas pixel size and sprite padding
« Reply #2 on: February 18, 2015, 03:56:01 AM »
Sure! The changes I made so far are all in UISprite (NGUI version 3.7.9):

Line 159:
min += Mathf.RoundToInt (pixelSize * (sp.paddingLeft + sp.paddingRight));

Lines 203-206:
int padLeft = Mathf.RoundToInt (pixelSize * mSprite.paddingLeft);
int padBottom = Mathf.RoundToInt (pixelSize * mSprite.paddingBottom);
int padRight = Mathf.RoundToInt (pixelSize * mSprite.paddingRight);
int padTop = Mathf.RoundToInt (pixelSize * mSprite.paddingTop);

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas pixel size and sprite padding
« Reply #3 on: February 18, 2015, 05:25:43 PM »
Thanks!