using UnityEngine;
using System.Collections;
public class Sidewalls_Init : MonoBehaviour {
public Color gradientFrom = new Color(255, 255, 255, 1);
public Color gradientTo = new Color(0, 0, 0, 1);
public float t = 1.0f;
void Start() {
//Sidewall_Object.GetComponent<MeshRenderer>().material.color = new Color(255, 18, 18, 1);
// gameObject.GetComponent<MeshRenderer>().material.color = new Color(255, 255, 255, 1);
}
void Update() {
float lerp = Mathf.PingPong(Time.time, t) / t;
gameObject.renderer.material.color = Color.Lerp(gradientFrom, gradientTo, lerp);
}
}
I’ve got code that I’ve placed above. The strange thing is, that if I start this, it, I mean, material ignores the entire coloring, about 90% of it’s time it’s white, another 10% of it’s time it’s black. It does “interpolate”, I see gradient effect from white to black, just white is there for so long time!
After some in-editor research, I found out that when Lerper is at position of rgba(45, 45, 45), you can see it normally change between white and black with 50/50 deal.
And he doesn’t give a nutcrack about how I change color in material itself. It’s like every, single, box, in, Unity, is, shouting, the color isn’t white at all but grayish, Inspector clearly knows, “this is not white!”. Every box that indicates color of material, swaps between real 45, 45, 45 and 0, 0, 0. But Editor and Game screens, both see swap between #FFF and #000.
I don’t understand it, it should change from A to B, but apparently 45, 45, 45 is already #FFF for Unity. Or I’m getting “brightness-blind”.
It couldn’t be camera issue, because Editor shows the same.
Don’t get me wrong, this is not a real issue to me, I can always just find out what #FFF means for Unity3D and use this RGBA code. But I’m just wondering why it’s not working.