Light.range Manual     Reference     Scripting  
Scripting > Runtime Classes > Light
Light.range

var range : float

Description

The range of the light.

See Also: Light component

JavaScript
// 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 example : 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

class example(MonoBehaviour):

public duration as single = 3.0F

private originalRange as single

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

def Example():
originalRange = light.range