Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Light.spotAngle

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

Description

The angle of the light's spotlight cone in degrees.

This is used primarily for Spot lights and has no effect for Point lights See Also: Light component.

	// 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 ExampleClass : 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 Example() {
        timeLeft = interval;
        light.type = LightType.Spot;
    }
}
import UnityEngine
import System.Collections

public class ExampleClass(MonoBehaviour):

	public interval as float = 0.3F

	public minAngle as float = 10

	public maxAngle as float = 90

	private timeLeft as float

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

	def Example() as void:
		timeLeft = interval
		light.type = LightType.Spot