I’m trying to change a material’s texture to black over time. Based on the camera’s changing “y” value.
I’m trying to convert the RGB to HSV so I can slide the value from 255 down to 0 and “fade it out” to black.
But my update function is just…not doing what I expect it to. No results. The material just sits there regardless of the camera’s y value.
public class SkyScript : MonoBehaviour {
GameObject sky;
Color color;
float value = 255;
float h, s = 0;
// Use this for initialization
void Start () {
sky = GameObject.Find("Sky");
}
// Update is called once per frame
void Update () {
value = 255- (int)Camera.main.transform.position.y;
color = sky.GetComponent<Renderer>().material.color;
Color.RGBToHSV(color, out h, out s, out value);
sky.GetComponent<Renderer>().material.SetColor("_MainTex", color);
}
}