Hello Guest

Author Topic: Size of Sprite  (Read 4693 times)

hromoydron

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Size of Sprite
« 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)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Size of Sprite
« Reply #1 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);

hromoydron

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Size of Sprite
« Reply #2 on: August 19, 2013, 12:21:37 pm »
Thank you! For demo sprites looks norm)