Camera.backgroundColor 背景颜色

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).

只在clearFlags被设置为 CameraClearFlags.SolidColor(或者设置为 CameraClearFlags.Skybox但是没有设置天空盒)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public Color color1 = Color.red;
	public Color color2 = Color.blue;
	public float duration = 3.0F;
	void Update() {
		float t = Mathf.PingPong(Time.time, duration) / duration;
		camera.backgroundColor = Color.Lerp(color1, color2, t);
	}
	public void Awake() {
		camera.clearFlags = CameraClearFlags.SolidColor;
	}
}
// ping-pong animate background color
//来回变化背景颜色

var color1 : Color = Color.red;
var color2 : Color = Color.blue;
var duration = 3.0;

// Set clear flags to color
//设置消除标识到颜色

camera.clearFlags = CameraClearFlags.SolidColor;

function Update () {
	var t : float = Mathf.PingPong (Time.time, duration) / duration;
	camera.backgroundColor = Color.Lerp (color1, color2, t);
}

参见:Camera.clearFlags 属性.

Page last updated: 2011-5-10