Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ivarhill on January 30, 2013, 07:57:39 PM

Title: Update image button sprites
Post by: ivarhill on January 30, 2013, 07:57:39 PM
I have a script that changes the sprites of an image button if certain conditions are met - however, the new sprites do not show unless I actively mouseover/press the buttons in question. How can I refresh the image button in order to show the new sprites instantly?
Title: Re: Update image button sprites
Post by: ArenMook on January 30, 2013, 08:11:38 PM
Set them via spriteName, not via sprite.
Title: Re: Update image button sprites
Post by: ivarhill on January 30, 2013, 08:15:09 PM
Hm - I'm setting them using the normalSprite, hoverSprite and pressedSprite properties of UIImageButton - isn't spriteName a UISprite property? Might be doing something wrong though...
Title: Re: Update image button sprites
Post by: ArenMook on January 30, 2013, 08:21:24 PM
Changing those won't update the current state of the background sprite -- you have to update it yourself via its spriteName property.
Title: Re: Update image button sprites
Post by: ivarhill on January 30, 2013, 08:21:52 PM
Ah, I see - thank you :)
Title: Re: Update image button sprites
Post by: ivarhill on January 30, 2013, 08:30:59 PM
I'm having a further issue with this - the sprite updates correctly now, but the scale is wrong - whenever I change the sprite through spriteName, the buttons are upscaled quite a bit and remains so until I mouse over them - any idea why this might be happening?
Title: Re: Update image button sprites
Post by: ArenMook on January 30, 2013, 08:31:59 PM
MakePixelPerfect() on it.
Title: Re: Update image button sprites
Post by: ivarhill on January 30, 2013, 08:34:31 PM
Thanks, got it all working now :)