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

var spotAngle : float

Description

The light's spotlight angle in degrees.

Used primarily for Spot lights. Alters the light cookie size on Directional lights. No effect for Point lights See Also: Light component

JavaScripts
// Change spot angle randomly between 'minAngle' and 'maxAngle'
// each 'interval' seconds.

var interval : float = 0.3;
var minAngle : float = 10;
var maxAngle : float = 90;
private var timeLeft : float;

timeLeft = interval;
light.type = LightType.Spot;

function Update () {
timeLeft -= Time.deltaTime;
if (timeLeft < 0.0) {
// time to change!
timeLeft = interval;
light.spotAngle = Random.Range( minAngle, maxAngle );
}
}

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
public float interval = 0.3F;
public float minAngle = 10;
public float maxAngle = 90;
private float timeLeft;
void Update() {
timeLeft -= Time.deltaTime;
if (timeLeft < 0.0F) {
timeLeft = interval;
light.spotAngle = Random.Range(minAngle, maxAngle);
}
}
void Awake() {
timeLeft = interval;
light.type = LightType.Spot;
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

public interval as single = 0.3F

public minAngle as single = 10

public maxAngle as single = 90

private timeLeft as single

def Update():
timeLeft -= Time.deltaTime
if timeLeft < 0.0F:
timeLeft = interval
light.spotAngle = Random.Range(minAngle, maxAngle)

def Awake():
timeLeft = interval
light.type = LightType.Spot