Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Tripwire on March 13, 2014, 10:35:52 AM

Title: UIButton disabled state bug
Post by: Tripwire on March 13, 2014, 10:35:52 AM
Hi ArenMook,

I think I have found a bug which appears when setting the UIButton.isEnabled = false;

I'm calling UIButton.isEnabled = false on a panel then the button is grey color (disabled color). But when I turn off the panel and turn the panel back on, the button is disabled but it has the normal color of the button.

How to reproduce:
Create button with a normal, hover and disabled color.
Disable the button at runtime
Turn the panel which holds the button off and back on.
The button now has the normal color instead of the disabled color
Title: Re: UIButton disabled state bug
Post by: ArenMook on March 14, 2014, 12:27:12 PM
I believe this was already addressed in 3.5.4, so give it a try after tonight's update.
Title: Re: UIButton disabled state bug
Post by: Im_Lp on May 26, 2014, 08:13:25 PM
I hate to bring back a thread from the dead but the issue is still ocurring on the latest version of NGUI (3.6.0)

I am creating a navigation bar which highlights the currently selected "tab" by changing the enabled state of the sprites on the bar. It appears that whenever I toggle the state via UIButton.isEnabled or MyUIButtonObject.collider.enabled it doesn't trigger redraws. I went over it countless times thinking it was the FSM I wrote for the nav bar messing state changes but all navigation passed the unit tests I set in place.

As observed in different threads, hovering on/off the button does trigger the sprite changes.

Thoughts?
Title: Re: UIButton disabled state bug
Post by: ArenMook on May 26, 2014, 11:50:01 PM
Did you ever change UIButton's defaultColor? Simply changing the sprite's color won't update the button.
Title: Re: UIButton disabled state bug
Post by: Im_Lp on May 27, 2014, 01:26:47 PM
I did, but I do not believe that is the issue since it's not a color related issue but a sprite state issue.

This is how the background UIButton component looks right now for each of the buttons on my bar.
(http://i.imgur.com/MOmaRht.png)

Now given 2 buttons A & B. Lets say Button A is currently on the "disabled" state. If I click Button B then A should be enabled and switch its sprite to the normal state, while button B should change to the "disabled" state. Like so:
(http://i.imgur.com/hnbolaN.png)

Instead what occurs is that Button A stays using the "disabled" state sprite but responds to clicks while B shows disabled.

(http://i.imgur.com/ui7V6pm.png)

Head-scratching note: is that if I hover my mouse over the buttons, the sprites change to the correct states.
Title: Re: UIButton disabled state bug
Post by: ArenMook on May 28, 2014, 05:39:39 AM
What you're doing doesn't make much sense to me. Why not us a toggle for this? You seem to be trying to mimic toggle functionality with the button script, which isn't what it was designed for. Look at the Tabs example that comes with NGUI.