Author Topic: Atlas padding not working how it should?  (Read 4825 times)

Tom G

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Atlas padding not working how it should?
« on: September 21, 2012, 06:21:56 PM »
Hi,

So I'm loving the 9-slice sprites feature of NGUI and generally it seems to work great. However, I've run into a problem and I'd like to confirm that I understand things correctly.  Here's the story...

I have two images for use as button states. The hover state has a glow around it, so to account for this in my artwork I have left a transparent border around the one that doesn't have a glow.  The first image shows how they look in Photoshop. They both export at 40x40 pixels.



Now, after bunching them both into an Atlas in Unity (with 'trim alpha' checked, and using the regular Unity packer), I see -- as expected -- some Padding has been added to one of the images to make up for the trimmed pixels.  The second image shows how the sprites look in the Atlas Inspector, after I've set up appropriate 9-slice Borders.



So my first question is: Should the preview not be showing the padding around the image?  Is this a bug in itself?  It seems to correspond with the fact that when I try to use these two sprites to make an Image Button, I see problems with image scaling. The third image shows how the mouse-over state looks.  It looks like the Padding is not doing its job.



Am I misunderstanding something here, or is this an issue?

Thanks,

Tom
« Last Edit: September 21, 2012, 06:27:04 PM by Tom G »

Tom G

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Atlas padding not working how it should?
« Reply #1 on: September 21, 2012, 06:36:50 PM »
I have worked around this issue for now, by selecting the Atlas in the Atlas Maker, then selecting the two offending images in the Project folder, un-ticking the 'Trim alpha' option and then hitting the Update button.

Still, I wouldn't mind knowing if I'm understanding things correctly or not!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas padding not working how it should?
« Reply #2 on: September 21, 2012, 10:52:39 PM »
Padding is intentionally ignored by sliced sprites, which is why you are seeing it like that. To be honest it's the first time I've seen this be an issue though. Importing the sprite with the trim alpha option disabled is indeed a proper work-around.

Tom G

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 12
    • View Profile
Re: Atlas padding not working how it should?
« Reply #3 on: September 22, 2012, 04:01:33 AM »
Okay, thanks as ever for your quick reply, Aren.