I want to make my camera background color turn red when I press space and five seconds later turn back to blue. It normally was just supposed to get red when I press space and It worked fine, but now I try to revert the color back to blue and It simply doesn’t work. Obviously I’m doing something wrong.
Here’s the code
using UnityEngine;
using System.Collections;
public class CameraBackGroundTest : MonoBehaviour
{
private Color red = Color.red;
private Color blue = Color.blue;
Camera cam;
void Start()
{
cam = GetComponent<Camera>();
}
IEnumerator Update()
{
if (Input.GetKeyUp ("space"))
{
cam.backgroundColor = red;
yield return new WaitForSeconds(5);
cam.backgroundColor = blue;
}
}
}
Thanks for the help!