Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: AshB on January 09, 2013, 01:27:34 PM
-
Hi,
I wanted to create a button that ll switch different weapon texturs and cylce between thm as i press thm. Is it possible to change texture of a button to different textures on every click ? or any other way to get switchable textures button ?
THNKS..
-
A button is just a script that may or may not be referencing actual widgets.
In your case, you want to change the spriteName of the button's background (which is an actual widget).
-
Thnks for the reply.
Can u tell me how to change the sprite of any button through script dynamically ?
-
Create a script and attach it to the UIButton. Cache the reference to the Background sprite (using GetComponentInChildren<> or directly in the editor) then implement the OnClick event. Change the name of the sprite using mySprite.spriteName it will update the sprite.
-
Thanks, I got it. Thnks for the reply.