Camera background
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);
}
}
Answer by okaybj · Dec 28, 2016 at 03:49 PM
Yeah it seems to update when I click on something outside of unity then click back on the player window. Also works when I update stereo camera. Also works when I exported the apk and tested it on my phone. But just won't update live in the play mode. Thanks for your response @vicarian
@okaybj Do you possibly have more than one camera in the scene? I tested in Unity 5.4.0 and it was working in play mode, though that shouldn't make a difference.
Your answer