言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

Light.color

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public var color: Color;
public Color color;
public color as Color

Description

ライトのカラーを設定する。

To modify the light intensity you change light's color luminance. Lights always add illumination, so a light with a black color is the same as no light at all. See Also: Light component.

	// Darken the light completely over a period of 2 seconds.
	function Update () {
		light.color -= Color.white / 2.0 * Time.deltaTime;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Update() {
        light.color -= Color.white / 2.0F * Time.deltaTime;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	def Update() as void:
		light.color -= ((Color.white / 2.0F) * Time.deltaTime)

さらに別の例:

	// Interpolate light color between two colors back and forth
	var duration : float = 1.0;
	var color0 : Color = Color.red;
	var color1 : Color = Color.blue;
	
	function Update () {
		// set light color
		var t : float = Mathf.PingPong (Time.time, duration) / duration;
		light.color = Color.Lerp (color0, color1, t);
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float duration = 1.0F;
    public Color color0 = Color.red;
    public Color color1 = Color.blue;
    void Update() {
        float t = Mathf.PingPong(Time.time, duration) / duration;
        light.color = Color.Lerp(color0, color1, t);
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public duration as float = 1.0F

	public color0 as Color = Color.red

	public color1 as Color = Color.blue

	def Update() as void:
		t as float = (Mathf.PingPong(Time.time, duration) / duration)
		light.color = Color.Lerp(color0, color1, t)