using UnityEngine; // Very simple script, just takes a light on start and slowly fades it to 0 // over the duration specified. [RequireComponent(typeof(Light))] public class FadingLight : MonoBehaviour { Light lightObj; public float duration; public bool isFading; float timer; float startIntensity; void Start() { lightObj = GetComponent(); startIntensity = lightObj.intensity; } void Update() { timer += Time.deltaTime; float t = timer / duration; t = Mathf.Clamp01(t); lightObj.intensity = Mathf.Lerp(startIntensity, 0, t); } }