drkgez
1
public Color32 upTop;
public Color32 upBottom;
public Color32 doTop;
public Color32 doBottom;
public Material skybox;
public float t = 0;
public float speed = 0.1f;
// Start is called before the first frame update
void Start()
{
upTop = new Color32(0, 221, 255, 0);
upBottom = new Color32(13, 0, 255, 0);
doTop = new Color32(13, 0, 255, 0);
doBottom = new Color32(255, 26, 0, 0);
}
// Update is called once per frame
void Update()
{
if(t >= 1)
{
t -= Time.deltaTime / speed;
}
if(t <= 0)
{
t += Time.deltaTime / speed;
}
skybox.SetVector("_Color1", Color.Lerp(upBottom, doBottom, t * Time.deltaTime));
skybox.SetVector("_Color2", Color.Lerp(upTop, doTop, t * Time.deltaTime));
}
I want the shader to keep changing between these colors, yet it doesnt work.
Hellium
2
void Update()
{
t = Mathf.PingPong(Time.time * speed, 1);
skybox.SetVector("_Color1", Color.Lerp(upBottom, doBottom, t);
skybox.SetVector("_Color2", Color.Lerp(upTop, doTop, t);
}