Legacy Documentation: Version 5.1
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Camera.backgroundColor

Switch to Manual
public var backgroundColor: Color;

Description

The color with which the screen will be cleared.

Only used if clearFlags are set to CameraClearFlags.SolidColor (or CameraClearFlags.Skybox but the skybox is not set up).

#pragma strict
// ping-pong animate background color
public var color1: Color = Color.red;
public var color2: Color = Color.blue;
public var duration: float = 3.0F;
var camera: Camera;
function Start() {
	camera = GetComponent.<Camera>();
	camera.clearFlags = CameraClearFlags.SolidColor;
}
function Update() {
	var t: float = Mathf.PingPong(Time.time, duration) / duration;
	camera.backgroundColor = Color.Lerp(color1, color2, t);
}