Author Topic: UpdateColor is not a member of UIButton  (Read 1844 times)

uberwleiss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
UpdateColor is not a member of UIButton
« on: March 19, 2014, 06:04:27 AM »
Hello,

I've Updated NGUI to the 3.5.4 r2 and i get the " 'UpdateColor' is not a member of 'UIButton' " eror.

I used to change the colors for buttons depending on whether the weapon is equipped, out of ammo, unequipped or locked. After changing colors for every state (hover, press etc), I'd call UpdateColor function so the color change is immediate. In the new NGUI, there's no UpdateColor function anymore in UIButton. How can I solve this problem as quickly as possible?

Thank you.

uberwleiss

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UpdateColor is not a member of UIButton
« Reply #1 on: March 19, 2014, 06:31:46 AM »
I've solved this by adding:

public void UpdateColor (bool shouldBeEnabled, bool immediate)
   {
      if (tweenTarget)
      {
         if (!mInitDone)
         {
            //mInitDone = true;
            OnInit();
         }
         
         Color c = shouldBeEnabled ? defaultColor : disabledColor;
         TweenColor tc = TweenColor.Begin(tweenTarget, 0.15f, c);
         
         if (tc != null && immediate)
         {
            tc.value = c;
            tc.enabled = false;
         }
      }
   }

To the UIButton.cs

Do you think this is ok? I hope it will not cause some problems. So far it works great, just as it were.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UpdateColor is not a member of UIButton
« Reply #2 on: March 20, 2014, 02:20:47 AM »
There is no UpdateColor because there is now SetState(). Use that instead.

smax

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: UpdateColor is not a member of UIButton
« Reply #3 on: April 16, 2014, 07:43:35 AM »
Had that same probleme too: tried the SetState() on a UIButton.

It does not appear in the completion.  Seems protected :
Console error : UIButtonColor.SetState(UIButtonColor.State, bool)' is inaccessible due to its protection level
(on 3.5.5 and 3.5.7)

Any ideas/examples on syntax on a UIButton ? (not a UIButtonColor)

Thank you very much

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UpdateColor is not a member of UIButton
« Reply #4 on: April 16, 2014, 11:15:28 AM »
Just make it public. I'll also make it public in the next update.