Author Topic: Strange problem with UILabel  (Read 5345 times)

Magic Frame

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Strange problem with UILabel
« on: February 24, 2015, 10:22:42 AM »
Hello I'm trying to change the color of my UILabel, but I have a strange problem

this line works well and change color -->  mylabel.color = Color.red;

but, this line not works --->  mylabel.color = new Color (230f,170f,22f);

I'm doing something wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Strange problem with UILabel
« Reply #1 on: February 24, 2015, 11:45:43 AM »
Color is 0-1 range. Color32 is 0-255 range. Check Unity's documentation.

What you should be doing instead is:

mylabel.color = new Color(0.9f, 0.7f, 0.1f);

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Re: Strange problem with UILabel
« Reply #2 on: February 24, 2015, 05:02:09 PM »
mylabel.color = new Color (230f,170f,22f);


another solution:  (isnt there a helper function for this?)

mylabel.color = new Color (230f / 255f,170f / 25ff ,22f / 255f);

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Strange problem with UILabel
« Reply #3 on: February 27, 2015, 04:34:22 AM »
Yeah, it's called Color32 :P

mylabel.color = new Color32(230, 170, 22);