Support => NGUI 3 Support => Topic started by: shadowdiver on May 02, 2013, 08:33:57 AM
Title: Change button-background on active state
Post by: shadowdiver on May 02, 2013, 08:33:57 AM
Hi,
how can i change the backgroundimage of an button, when it is clicked.
For example there is a menu like the build-menu of simcity. You click one of the buttons and it appears some sort of sub-menu. Now the clicked button looks different to the others. So you can see, you are in that special submenu. An other simple example is a button to switch windowed-mode to full-screen and back. It is the same button but an other image you will see.
Is there something like:
function OnClick(){
// do something special
// change the backgroundimage of this button
}
Title: Re: Change button-background on active state
Post by: ArenMook on May 02, 2013, 08:42:16 AM
Don't use a button. Create a sprite, add a collider to it (Alt+Shift+C), add a custom script to it that changes the sprite in OnClick.
Title: Re: Change button-background on active state
Post by: shadowdiver on May 04, 2013, 06:07:56 AM
Quote
changes the sprite in OnClick
And how can i do that?
Title: Re: Change button-background on active state
Post by: Nicki on May 04, 2013, 12:15:59 PM