- Home /
Color() Troubles
I can't seem to grasp how Color works in C#. I'm trying to darken a sprite when night falls, using SpriteManager. SpriteManager is changing the colors (I can get a black sprite, or a blue sprite, red sprite, green sprite, etc).
For debug purposes I am using a gray scale sprite, and I'm attempting to color it light blue or dark navy blue depending on time... It doesn't seem to work though.
if (_night & _transition)
{
Color _color = new Vector4(17f, 55f, 74f, 255f).normalized;
Main.level.skySprite.SetColor(_color);
_transition = false;
}
if (_day & _transition)
{
Color _color = new Vector4(205f, 227f, 238f, 255f).normalized;
Main.level.skySprite.SetColor(_color);
_transition = false;
}
did you tried
Color _color = new Color(0.1f, 0.1f, 0.1f, 1f);
Answer by whydoidoit · Mar 24, 2014 at 07:57 AM
Colour uses float 0-1 not int 0-255. Color32 uses the int version, you want to divide everything by 255f.
Your answer
![](https://koobas.hobune.stream/wayback/20220613141028im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
SpriteManager 1, Set animation to single frame 0 Answers
Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer