New to Unity. Just want to animate the background fading from blue to red. using this code provided in unity docs but it doesnt work for me. i can see the camera background fading from blue to red in the inspector but it does not do it while playing
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public Color color1 = Color.red;
public Color color2 = Color.blue;
public float duration = 3.0F;
Camera MainCamera;
void Start()
{
MainCamera = GetComponent<Camera>();
MainCamera.clearFlags = CameraClearFlags.SolidColor;
}
void Update()
{
float t = Mathf.PingPong(Time.time, duration) / duration;
MainCamera.backgroundColor = Color.Lerp(color1, color2, t);
}
}