Author Topic: [solved]Changing sprite at runtime  (Read 2895 times)

skinsomnia

  • Guest
[solved]Changing sprite at runtime
« on: April 22, 2013, 03:57:56 AM »
Hi,
I have a prefab of a button. I instantiate buttons at runtime. Each button has a Sprite child object on it.

At runtime, when I instantiate each button I set it's UISprite.spriteName accordingly, in order to show the right Sprite for each button. Sprites change, but they all keep the scale of the original sprite which was in the prefab.

Is it possible to have the new Sprites appear with their own original size and scale.

Thanks,
Zdravko
« Last Edit: April 24, 2013, 02:22:22 AM by Nicki »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changing sprite at runtime
« Reply #1 on: April 22, 2013, 01:58:58 PM »
sprite.MakePixelPerfect()

skinsomnia

  • Guest
Re: Changing sprite at runtime
« Reply #2 on: April 24, 2013, 01:49:39 AM »
Thx a lot!