Author Topic: Looks like Unity 5.6 broke atlas generation  (Read 3616 times)

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Looks like Unity 5.6 broke atlas generation
« on: May 05, 2017, 01:33:22 AM »
Fairly easy to reproduce, just regenerate the atlas over and over again (e.g. by making small changes to one of the bitmaps included into it and invoking the add to atlas context option) - random sprites have a chance of getting corrupted boundaries and dimensions - for example, a number of 48x48px .png files which were previously correctly imported into an atlas turned into 30x30px sprites and 23x16px sprites in some cases. Not sure what triggers that, maybe 5.6 changed something NGUI relied on to determine image dimensions?

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Looks like Unity 5.6 broke atlas generation
« Reply #1 on: May 05, 2017, 08:28:16 PM »
Here are some screenshots of the issue. First, the list of atlas sprites under Unity 5.5, for reference on their real proportions (e.g. notice how all icon_issue* sprites are strictly square):



Now, here is Unity 5.6 atlas after 48x48px icon_data_01.png was added to it (ignore a few more icons like icon_help being present, Unity 5.5 example just happened to have them trimmed):



Notice how icon_data_01 sprite was generated incorrectly (it is not square at all and has incorrect border) and how icon_issue* sprites started losing their square dimensions? Next, here is a screenshot after two more 48x48px sprites are added to the atlas in Unity 5.6 (icon_data_02 and icon_data_03):



Now distortion affects more than a dozen of sprites. I have no idea how to fix this and this corrupts any UI where widget sizes are driven by native sprite resolutions, so I had to revert all my atlases and UI prefabs and started using Unity 5.5. to update them. Judging from the severity of the bug being dependent on the number of new sprites, I'd wager a guess that atlas update misreads the borders and dimensions of sprites around areas where new sprites are packed in. Going to experiment with switching to non-native packer to see if this goes away.

bac9

  • Full Member
  • ***
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 113
    • View Profile
Re: Looks like Unity 5.6 broke atlas generation
« Reply #2 on: May 05, 2017, 08:36:21 PM »
Alright, looks like Unity 5.6 packer is broken while "custom packer" from NGUI works correctly. Check out the result of adding aforementioned 3 48x48 .png files to the same atlas using the custom packer:



It's perfect. The only quirk is the fact that sprites in the scene do not update on atlas rebuild from Unity packer to NGUI packer, so for a brief moment everything in your scene looks completely broken, but restarting the scene updates everything to look correctly.

So, based on this, it's probably worth adding a #if UNITY_5_6 check to Atlas Maker and killing "Unity Packer" option there until Unity fixes their packer; as well as checking existing atlases for that toggle if they are modified for the first time under a Unity 5.6 project. What do you think? :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Looks like Unity 5.6 broke atlas generation
« Reply #3 on: May 13, 2017, 11:20:36 AM »
Curious.. I haven't noticed any issues on my end but then again I don't think I touched the atlas much. I'll default to the custom packer for the next version onward. Thanks for letting me know.