- Home /
Quad Gradual Colour Change
Hi,
I'm trying to change the colour of a quad, used as background. Specifically I'm attempting to change the colour of each r, g and b values as a Color object incrementally within a Update() method. So far I'm not having much luck. I've noticed the following line of code will change the quads colour accordingly...
GetComponent<Renderer>().material.color = Color.black;
However if i attempt the following...
private Color skyColour;
private float r, g, b;
void Start ()
{
r = 206f;
g = 140f;
b = 21f;
skyColour = new Color(r,g,b);
}
void Update ()
{
//skyColour = new Color(r,g,b);
GetComponent<Renderer>().material.color = new Color(r,g,b);
}
It doesn't assign the desired colour. Even including alpha values. The colour is set too white. The shader is set to Unlit/Color.
I've breifly looked into solving the problem myself but I figured posting up here might help save time whilst looking into it. Any help would be muchly appreciated
Answer by Dave-Carlile · Jul 02, 2015 at 10:16 PM
So the only time it doesn't give you the color you expect is when you use color attributes you specify? What if you use some of the other standard colors - Color.green, Color.red, Color.yellow, Color.blue... how do those look?
What color space are you rendering in? Although I'm not completely sure if that is only affected by lights, it's worth checking out.
Hey Dave, yes. All of the other standard colours work as intended when applied. I had a quick look through the link you gave, and have found what i'm trying to acheive can be done through lighting. Thanks
Follow this Question
Related Questions
My foreach or the Resources.LoadAll Is not getting the information I need 2 Answers
Image UI color not changing when sprite is set via script 0 Answers
how to change color in unity scripting overtime?,how to change color gradually with C# 2 Answers
Color of some instantiated objects differs from the normal ones. 1 Answer