Author Topic: UIButton bug with multiple tween targets in disabled state  (Read 6293 times)

stepnoy

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
UIButton bug with multiple tween targets in disabled state
« on: November 24, 2014, 11:46:08 AM »
Hello,

We had found a bug. When button becomes disabled we need to change a sprite and an inner label color as well. So we was added a second UIButton component to the button object. We have a correct behavior when button state changes for all states except disabled state. Label doesn't want to change it's color.

Hierarchy
-Button object (Collider, Sprite, UIButton (Tween target = Button object), UIButton (Tween target = Label))
--Label

So we had found a workaround to make this work, but it doesn't seems like a true solution. As far as I can see bug is connected with some code inside "isEnabled" property. When the first UIButton isEnabled becomes false it disables shared collider,  then the second UIButton already have isEnabled in false (because of disabled collider) so it doesn't do anything to change it's color.

We are using this code to make it work.

  1.     void SetButtonState(GameObject button, bool state) {
  2.         var components = button.GetComponents<UIButton> ();
  3.  
  4.         foreach (var c in components) {
  5.             //
  6.             // Ничему не удивляемся - так надо :)
  7.             c.isEnabled = !state;
  8.             c.isEnabled = state;
  9.         }
  10.     }
  11.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton bug with multiple tween targets in disabled state
« Reply #1 on: November 25, 2014, 01:25:18 AM »
Use the SetState function.

stepnoy

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UIButton bug with multiple tween targets in disabled state
« Reply #2 on: November 25, 2014, 06:48:44 AM »
Use the SetState function.

We should use SetState for each UIButton?

eduardo_coelho

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIButton bug with multiple tween targets in disabled state
« Reply #3 on: November 26, 2014, 05:36:37 PM »
I have the same issue.
I'm trying to deactivate a button using `BtMenu.isEnabled = false;`, the button is deactivated (stop receiving touch events) but the children widgets (sprites/labels) don't have their appearance updated to the `disabled` Color. Looks like a 'famous' issue in this forum.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton bug with multiple tween targets in disabled state
« Reply #4 on: November 26, 2014, 08:54:38 PM »
Yes, GetComponents<UIButton>(), iterate through them and call SetState(UIButton.State.Disabled, true) on all of them.