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

スクリプト言語

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

Light.range

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 range: float;
public float range;
public range as float

Description

ライトの大きさを設定する。

See Also: Light component.

	// Pulse light's range between original range
	// and half of the original one
	
	var duration : float = 3.0;
	private var originalRange : float;
	originalRange = light.range;
	
	function Update() {
		var amplitude : float = Mathf.PingPong( Time.time, duration );
		// transform from 0..duration to 0.5..1 range
		amplitude = amplitude / duration * 0.5 + 0.5;
		// set light range
		light.range = originalRange * amplitude;
	}
using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    public float duration = 3.0F;
    private float originalRange;
    void Update() {
        float amplitude = Mathf.PingPong(Time.time, duration);
        amplitude = amplitude / duration * 0.5F + 0.5F;
        light.range = originalRange * amplitude;
    }
    void Example() {
        originalRange = light.range;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public duration as float = 3.0F

	private originalRange as float

	def Update() as void:
		amplitude as float = Mathf.PingPong(Time.time, duration)
		amplitude = (((amplitude / duration) * 0.5F) + 0.5F)
		light.range = (originalRange * amplitude)

	def Example() as void:
		originalRange = light.range