Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: uberwleiss on March 19, 2014, 06:04:27 AM

Title: UpdateColor is not a member of UIButton
Post by: uberwleiss 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.
Title: Re: UpdateColor is not a member of UIButton
Post by: uberwleiss 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.
Title: Re: UpdateColor is not a member of UIButton
Post by: ArenMook on March 20, 2014, 02:20:47 AM
There is no UpdateColor because there is now SetState(). Use that instead.
Title: Re: UpdateColor is not a member of UIButton
Post by: smax 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
Title: Re: UpdateColor is not a member of UIButton
Post by: ArenMook on April 16, 2014, 11:15:28 AM
Just make it public. I'll also make it public in the next update.