Skip to main content

LightFader

A class in Root.Township, the global namespace.

Fades a PlatformLight on and off along curves when IsLit changes, with an extra intensity multiplier. A component next to the light.

Constructors​

MemberWhat it is
LightFader()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

7 private and internal fields
MemberWhat it is
private float baseIntensityThe light's intensity at start, the 1.0 point of the curves.
private float currentUnmultipliedIntensityCurrent faded intensity before Multiplier.
private bool isLitBacking field for IsLit.
private AnimationCurve lightEndMultiplierCurve used when fading out.
private AnimationCurve lightStartMultiplierCurve used when fading in.
private float multiplierBacking field for Multiplier.
private PlatformLight targetThe light being faded.

Properties​

MemberWhat it is
bool IsLit { get; set; }Turns the light on or off with a fade.
float Multiplier { get; set; }Extra intensity multiplier applied on top of the fade.

Methods​

3 private and internal methods
MemberWhat it is
private void Awake()Reads the light's base intensity, turns the light off, and starts fading in if isLit is set.
private IEnumerator FadeLight() (iterator)Coroutine that plays the start or end curve from the point closest to the current intensity.
private float FindClosestTime(AnimationCurve curve, float value, int steps)Samples a curve to find the time whose value is nearest the given one.

Used in​

Members of other types that take, return or hold a LightFader: