SpritePacker and sprite boundaries

Hi,

i have a spritesheet like this:

I pack the spritesheet in atlas like this:

As you can see, the rect boundaries of the sprite are messed up by the atlas.
I was expecting something like this:

I edited the image to show you… the gap, the right padding from left bound, is gone when Unity packs the sprite.

What i need is to get the single spriteSheet and slice it by code at runtime basing on his rect canvas.

Something like:

for (int c = 0; c < numFrames; c++)
{
spriteArray

 = Sprite.Create(atlasTexture, new Rect((int)sourceSprite.textureRect.x + (c * h), (int)sourceSprite.textureRect.y, h, h), origin, 1);
}

[B]sourceSprite.textureRect.x, y[/B] is the sprite coord inside the atlas
[B]h[/B] is the frame size of the sprite (for example, a 256x256 frame in a 6 frames spritesheet will result in the 1536x256 texture)

Can i pack and retrieve the [B]exact [/B]original bounds? Seems this is due to the blend made by the packer which wants to trim and overlay some room occupied by alpha channel.

Solved, i had to set the texture as full rect in the importer.

1 Like