Author Topic: New sprite sizes after updating an atlas  (Read 2803 times)

HVS Brian

  • Guest
New sprite sizes after updating an atlas
« on: November 27, 2012, 08:25:24 PM »
Hey gang!

A couple weeks ago we upgraded from the Trial version of NGUI to Pro version 2.2.2.  Today we updated from Unity version 4.0.0f6 to version 4.0.0f7 and discovered a strange issue that we can't put our fingers on.  It's a little confusing, so I'll try to keep the explanation simple.

In Unity 4f6, we added a texture in our project; let's call it Texture A.  Let's also say that Texture A's dimensions are 1024*768 and that it is 32-bit with alpha.  We added Texture A to an atlas and the packed size of the corresponding Sprite A (after trimming the alpha) is 800*500.  We create a prefab with Sprite A and we're on our merry way.

After moving to Unity 4f7, we mark Texture A - and only Texture A - for update inside the atlas, despite not having made any changes to Texture A.  We update the atlas and now Sprite A is 950*675.  Confused, we go back to the Texture A in Photoshop and drag a marquee around the non-alpha region, approximating the expected dimensions of the Sprite A.  The values essentially match.

So, this presents a number of questions, most of which I have no answers to.  Is this a bug?  Is this the result of a bug fix?  Were Sprite A's original dimensions generated from an even older version of Texture A that was never updated in the atlas?  It seems like more than a simple coincidence that we discovered this the day of a Unity upgrade, but since this version has only been out a short time, I don't know how many other NGUI users have been working in the exact same development environment long enough to see this.  I also haven't seen any evidence on the other sites/forums of this issue, so perhaps I'm just crazy!

As I said, I don't really know the answers at this point.  However, I felt it was worth throwing it out there in case anyone else has experienced the same issue.  Any feedback would be appreciated!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: New sprite sizes after updating an atlas
« Reply #1 on: November 28, 2012, 02:00:28 AM »
Transparent pixels always get cut away. It's intentional. You don't need them there as they aren't visible. They get replaced with padding instead so that when you bring the sprite into the scene, it will look correct.

You should also update your NGUI. 2.2.2 isn't 100% 4.0-compatible. You need 2.2.6c.

HVS Brian

  • Guest
Re: New sprite sizes after updating an atlas
« Reply #2 on: November 28, 2012, 03:36:39 PM »
Thanks for the response, Aren.  I understand the concept behind the trimming of the transparent pixels; my dilemma has more to do with the apparent fluctuation of the sprite size despite no change to the source asset texture.  For now, I am willing to accept the possibility that Texture A was changed (i.e. re-sized) sometime between the original atlas creation and this current revision and update attempt.

(Thanks as well for the advice about the upgrade!)