Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


spotAngle

The angle of the spot light's cone in degrees.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Property
  • Namespace: UnityEngine
  • Assembly: UnityEngine.CoreModule
public float spotAngle { get; set; }

Remarks

This is used primarily for LightType.Spot lights and has no effect for LightType.Point lights Additional Resources: Light component.

Examples

using UnityEngine;public class Example : MonoBehaviour{ // Change spot angle randomly between 'minAngle' and 'maxAngle' // each 'interval' seconds. float interval = 0.3f; float minAngle = 10; float maxAngle = 90; float timeLeft; Light lt; void Start() { lt = GetComponent<Light>(); lt.type = LightType.Spot; timeLeft = interval; } void Update() { timeLeft -= Time.deltaTime; if (timeLeft < 0.0) { // time to change! timeLeft = interval; lt.spotAngle = Random.Range(minAngle, maxAngle); } }}