Author Topic: Set UISprite color not working with custom colors  (Read 3003 times)

hjbaard

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Set UISprite color not working with custom colors
« on: October 31, 2013, 02:24:57 AM »
Hi,

I'm trying to set the background color of a button in script (c#)
When I'm using:
_background.color = Color.black; //(_background is a UISprite instance)
It works fine.

But when I try this:
_background.color = new Color(93f, 106f, 114f); //(_background is a UISprite instance)
Nothing happens....

Is this a bug or do I do something wrong here?

scanmaster_k

  • Guest
Re: Set UISprite color not working with custom colors
« Reply #1 on: October 31, 2013, 02:35:19 AM »
If I´m not mistaken colors are a floating value between 0 - 1 so 93f gets capped to 1.0

hjbaard

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: Set UISprite color not working with custom colors
« Reply #2 on: October 31, 2013, 02:44:48 AM »
If I´m not mistaken colors are a floating value between 0 - 1 so 93f gets capped to 1.0

Thanks! That was the problem :)

Tip:
I found out that if you want to use byte codes voor colors you can use Color32. For example:
new Color32(93, 106, 114, 255)
« Last Edit: October 31, 2013, 02:58:19 AM by hjbaard »