Light 灯光

Inherits from Behaviour

Script interface for light components.


Use this to control all aspects of Unity's lights. The properties are an exact match for the values shown in the Inspector.


Usually lights are just created in the editor but sometimes you want to create a light from a script:


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	void Start() {
		GameObject lightGameObject = new GameObject("The Light");
		lightGameObject.light.color =;
		lightGameObject.transform.position = new Vector3(0, 5, 0);
function Start () {
	// Make a game object
	var lightGameObject : GameObject = new GameObject("The Light");

	// Add the light component

	// Set color and position
	lightGameObject.light.color =;

	// Set the position (or any transform property) after
	// adding the light component.
	lightGameObject.transform.position = Vector3(0, 5, 0);


Inherited members继承成员

Inherited Variables继承变量

Inherited Functions继承函数

Inherited Class Functions继承类函数

Page last updated: 2011-3-30