Author Topic: BUG with NGUI setting UIButtons to their disabled color  (Read 10137 times)

bogdandude

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
BUG with NGUI setting UIButtons to their disabled color
« on: October 31, 2013, 04:20:34 PM »
I believe there's a bug with the latest 3.x NGUI versions:

Many buttons in the game turn grey (their disabled color). Those are just random buttons.

Can you check your custom script execution order? And see if some button initialization to get them enabled/disabled takes place at the wrong time?

Some buttons stay disabled forever (we're not calling any code for that -> the UIButton component gets disabled), while some get enabled again, but their color doesn't change back until you hover them.

bogdandude

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #1 on: October 31, 2013, 04:41:51 PM »
I tracked the bug to this (in UIButtonColor):

Debug.LogWarning(NGUITools.GetHierarchy(gameObject) + " has nothing for UIButtonColor to color", this);
               enabled = false;

so it appears your code doesn't pick up any tweenTarget.renderer for some of the UIButtons, and it disables them (that's not what I want :)

Could you please look into it? And let me know if you plan to change this, or we should be changing something on our side.

Thanks a lot!


bogdandude

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #2 on: October 31, 2013, 04:55:14 PM »
So all buttons get greyed out if they don't have a 'Target' (tweenTarget) set in the editor.
If that's not set, it picks the button gameobject itself, which never has a renderer attached (the images/text are children of that game object).

I guess you also made a single inspector editor for UIButton + UIButtonColor, so it's hard to just remove the UIButtonColor component, if I don't want anything colored when hovering/pressing/disabling the button.

So do you think I should wait for a fix, or should I manually set a 'Target' for each button with such problems?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #3 on: November 01, 2013, 08:13:44 AM »
Buttons get "greyed out" if they don't have a collider on them. No collider means no events, so the button is basically disabled.

knifesk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #4 on: November 01, 2013, 08:31:03 AM »
Adding to Aren. I had this problem and this occurs when button has no event associated too. So if you're sketching up a GUI it will turn to disabled the buttons.

bogdandude

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #5 on: November 04, 2013, 08:34:16 AM »
Hey Aren!

The buttons have colliders, and they get grayed out with or without associated events.

As I told you, they stop getting greyed out when adding a 'Target', so they'd have something to color..
But in some cases, I don't want them to color any of their children...

Could you please look into it?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #6 on: November 04, 2013, 12:11:11 PM »
I just tried it. If I clear the Target, nothing happens because there is nothing to color. Are you setting the target to null at run-time after Start() or something?

bogdandude

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #7 on: November 04, 2013, 12:41:01 PM »
Here are some steps:


1 Create a button using your UI Widget wizard (choose a colored texture, so you'd see when it gets greyed out).
2 Maybe also add a UIButtonScale, to see when you're hovering it
3 Remove the Target from the UIButton, in inspector (set it to none).

When you hit play, the button gets disabled (the UIButton component is disabled).

The UIButtonScale still works, and we have a separate component, which links your click events to C# OnButtonClick events, so the buttons work even if that UIButton component is disabled.. it's just greyed out.

So do you think we're doing it wrong, or would you like to change it in the next versions?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: BUG with NGUI setting UIButtons to their disabled color
« Reply #8 on: November 05, 2013, 07:09:43 AM »
Oh the component gets disabled. I thought the button goes into the disabled state visually.

Line 124 of UIButtonColor.