Author Topic: UIButton color not changing properly  (Read 1175 times)

vicciu

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 2
    • View Profile
UIButton color not changing properly
« on: June 19, 2014, 12:04:49 PM »
Hello. For a few days I am trying to get the UIButton to work the way I want, but with no luck. Basicaly I am trying to change the color of a button at runtime, however the effect is visible only after hovering or clicking it. The code I am using is this:
   ofl_color.defaultColor=new Color(225f / 255f, 200f / 255f, 150f / 255f, 1f);
   ofl_color.hover=new Color(225f / 255f, 200f / 255f, 150f / 255f, 1f);
   ofl_color.pressed=new Color(225f / 255f, 200f / 255f, 150f / 255f, 1f);
It should normally change the button color immediately, however as I said earlier, the color changes only after it changes it's state. Does anyone have a solution to this problem?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton color not changing properly
« Reply #1 on: June 19, 2014, 06:38:57 PM »
ofl_color.tweenTarget.GetComponent<UIWidget>().color = someNewColor;

P.S. I'll add UIButton.UpdateColor() method to the next update to make it easier in the future.