Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Donkey111 on March 31, 2014, 11:43:38 PM

Title: Bug using sprite.name to switch sprites
Post by: Donkey111 on March 31, 2014, 11:43:38 PM
Hi I have three generic sprites I use to display enemies before entering a level. I switch out the enemies using a script similar to this:

MySprite.spriteName = "TextureNameOfEnemy"

My problem is that the enemy is also a button (to get info on his stats). When you scroll over the enemy, the UIScale script makes him bigger. During this process he switches from his new sprite name back to the placeholder sprite!

I have a similar issue with a level background that switches from the "complete" back to the "unlocked." Same issue -- I set the sprite using .spritename but when I scroll over it with the mouse at runtime it scales and switches back to the "original" unlocked sprite.

Any suggestions?
Title: Re: Bug using sprite.name to switch sprites
Post by: AGB on April 01, 2014, 01:40:29 AM
Seems, that you have UIButton script on this sprite and have to set not only sprite.spriteName, but also uiButton.normal sprite, uiButton.hover sprite and so on.
Title: Re: Bug using sprite.name to switch sprites
Post by: Donkey111 on April 01, 2014, 11:07:25 PM
You are right AGB! Thanks!!!