Change color of Image 4.6


Im facing problem in changing Image Color.(Image Unity 4.6)

  bgImgs[0].color = Color.Red;       //Works Fine

but when i set my own RGB values it shows White Color Only

  bgImgs[0].color = new Color(4f, 180f, 231f);     //White Color 

I want to set my own color…plz help

The Color class uses values between 0.0 and 1.0, so you need to normalize your values into that range. From the reference:

Each color component is a floating
point value with a range from 0 to 1.

Alternately you can use the Color32 class which does use values in the 0 to 255 range:

bgImgs[0].color = new Color32(4, 180, 231);

The Color32 class will get implicitly converted to a Color class.

Each component of Color range from 0.0f to 1.0f. You can simply switch to Color32 in your case since that accepts byte components 0 to 255 instead.