2D Toolkit Forum

2D Toolkit => Support => Topic started by: hromoydron on August 19, 2013, 09:25:01 am

Title: Size of Sprite
Post by: hromoydron on August 19, 2013, 09:25:01 am
How I can set same size(xy) for all sprites? (I use demo sprites and all they have different size)
Title: Re: Size of Sprite
Post by: unikronsoftware on August 19, 2013, 09:59:22 am
Its going to look really really ugly due to filtering and mipmaps and what not, but you can do it by scaling them by the correct amounts.

1. Get the size of one of the sprites
Vector3 sizeA = spriteA.CurrentSprite.GetUntrimmedBounds().size;

2. Get the size of sprite B
Vector3 sizeB = spriteB.CurrentSprite.GetUntrimmedBounds().size;

3. Calculate scale of sprite B to be the same as sprite A.
spriteB.scale = new Vector3( sizeA.x / sizeB.x, sizeA.y / sizeB.y, 1);
Title: Re: Size of Sprite
Post by: hromoydron on August 19, 2013, 12:21:37 pm
Thank you! For demo sprites looks norm)