- Home /
Unity3D -Trying to decrease color values when it equals to zero and curious result
0 down vote favorite This is hot case. In sense that It has no explanation even in suggestions.
So.
I have are cubes in scene.
In cycle I start coroutine for every cube, and this coroutine do next things:
It changes color of cube from black(0, 0, 0) to red(1, 0, 0) and then do revers action. In my code, in part, where I return color from red to black, I decrease values of G and B fields. Why would I do that? I would do that if I forgeted change these lines after copypast from action where I change color from black to red when it was not red, and when I changed R and G and B.
private IEnumerator CororRoutine(Material cubeMaterial)
{
float coff = 1f;
while (cubeMaterial.color.r < 1.0f)
{
cubeMaterial.color = new Color(
cubeMaterial.color.r + coff * Time.deltaTime,
0.0f,
0.0f);
yield return new WaitForEndOfFrame();
}
while (cubeMaterial.color.r > 0.0f)
{
cubeMaterial.color = new Color(
cubeMaterial.color.r - coff * Time.deltaTime,
cubeMaterial.color.g - coff * Time.deltaTime,
cubeMaterial.color.b - coff * Time.deltaTime);
yield return new WaitForEndOfFrame();
}
}
So, there is a very strange things happens. Screenshot: http://i.stack.imgur.com/K3WDm.png
As you can see, cubes that already have changed in both ways, have a little red shade. BUT. Values in their albedo color in material exactly (0, 0, 0). On screenshot you can see kind of red shade on material.
If you know something, that can bring me some understanding of what here happened, It would be really helpful.