Author Topic: Help on UIWidget / UISprite coloring of the ColorTint?  (Read 2865 times)

SuperTalesNat

  • Guest
Help on UIWidget / UISprite coloring of the ColorTint?
« on: May 13, 2013, 04:10:54 AM »
So i've been trying to get this to work to no avail.

There's multiple objects in the hierarchy that all need to be changed, hence the for loop.

Any help would be GREATLY appreciated.


  1.         Color RecColor = new Color (0,255,0,255);
  2.                
  3.                 UISprite[] recColor = RecBorder.GetComponentInChildren<UISprite>().color;
  4.                
  5.                 foreach (UISprite u in recColor)
  6.                 {
  7.                         recColor = RecColor;
  8.                 }
  9.  

dlewis

  • Guest
Re: Help on UIWidget / UISprite coloring of the ColorTint?
« Reply #1 on: May 13, 2013, 04:56:53 AM »
You're never actually accessing the sprite (and there for the color component) in the for loop

SuperTalesNat

  • Guest
Re: Help on UIWidget / UISprite coloring of the ColorTint?
« Reply #2 on: May 13, 2013, 10:47:21 AM »
Duhr, that'll teach me to try and code, and then ask a dumb question at 2am.

Got a good nights sleep (kind of) and saw the issue this morning as well.

   
  1.         Color RecColor = new Color (0,255,0,255);
  2.                
  3.                 UISprite[] recColor = RecBorder.GetComponentsInChildren<UISprite>();
  4.                
  5.                 foreach (UISprite u in recColor)
  6.                 {
  7.                         u.color = RecColor;
  8.                 }
  9.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Help on UIWidget / UISprite coloring of the ColorTint?
« Reply #3 on: May 13, 2013, 10:55:54 AM »
255 is invalid when creating a Color. Color values range from 0 to 1. You're creating a Color, passing Color32's parameters there.