Support => NGUI 3 Support => Topic started by: Zenneth on August 09, 2012, 06:41:25 AM
Title: How to Deactivate Button, Turn Button into switch
Post by: Zenneth on August 09, 2012, 06:41:25 AM
Hi,
Let say that I have 2 GameStates, and depending on which state the game is in, The Buttons input will either be disable or enable.
While Disable, no input can be made, and the color tint will be gray out. While Enable, buttons will return to default color and be in OFF State, then become On State if pressed.
For Disable The fastest way that I could gather at the moment is simply to change color tint to grey and disable BoxCollider. But I feel that this is not an appropriate method of utilizing NGUI.
For Enable I don't know how to change NGUI Button into a switch.
Can anyone give me any suggestion?
THX in advance.
Title: Re: How to Deactivate Button, Turn Button into switch
Post by: PhilipC on August 09, 2012, 09:12:01 AM
If i am reading this correctly you want something like a "sticky" button where the button stay's pressed until pressed again. You would have to write your own script for that (very easy).
If you override UIButton.OnPress(bool) and keep track of presses and based on the current state change the color or not (you would be ignoring the isPressed = false)
UIButton also has a .isEnabled which disables the collider on the button and changes its color to the disabled color.
Title: Re: How to Deactivate Button, Turn Button into switch
Post by: Zenneth on August 09, 2012, 09:17:45 AM