Author Topic: Why NGUI trim alpha on UI2Sprite ?  (Read 3402 times)

MatthieuG

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Why NGUI trim alpha on UI2Sprite ?
« on: April 17, 2014, 09:12:49 AM »
Hi !

Why when I use a sprite with UI2dSprite the size of the texture is different from the size in asset folder ?
Here the preview in the asset, the size is 96x96 :
http://picpaste.com/pics/asset_sprite-kHiPQe4A.1397742166.PNG
Here the preview in UI2DSprite, the size is 60x82 :
http://picpaste.com/pics/ui2dsprite-e7nwrnUd.1397742198.PNG

Can I disable this behaviour ?
The problem is when I switch the platform (Standalone to Android), the picture is no more trimmed but UI2DSprite dimensions keep the same, so the picture looks bad.

I'm using NGUI 3.5.6, 2d UIroot with pixel perfect.

Thank for your help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Why NGUI trim alpha on UI2Sprite ?
« Reply #1 on: April 17, 2014, 01:10:20 PM »
That's done by Unity, and is part of why 2D sprites can't be used by NGUI properly if they've been atlased by Unity. Don't use this functionality until Unity 4.5+ (which is when the missing functionality will be added in Unity).

MatthieuG

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Why NGUI trim alpha on UI2Sprite ?
« Reply #2 on: April 30, 2014, 07:40:39 AM »
Thank you for the details.

Unfortunely, I have to use Unity 2D Sprite, BUT I finally found a solution to force Unity to don't trim alpha :
  • Switch to the Standalone platform,
  • In asset folder, select the image file,
  • Set the type to "Advanced",
  • Set Non power of 2 to "none",
  • Set wrap mode to "Clamp"
After that, you can switch to different platform, the sprite size keep the same.