Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


BackgroundGradient

Color gradient that can be used as a Background, mirroring the CSS linear-gradient() / radial-gradient() functions.
Read time 1 minuteLast updated 8 days ago

Definition

public struct BackgroundGradient : IEquatable<BackgroundGradient>

Remarks

A default-constructed BackgroundGradient has no color stops and is treated as "no gradient" — see BackgroundGradient.IsEmpty.

Properties

Property

Description

angleAngle of a linear gradient, in radians, measured clockwise from "to top" (CSS convention, matching
linear-gradient(0deg, ...)
). Ignored for radial gradients.
positionCenter of a radial gradient, expressed as a fraction in [0,1] of the element box (0 = top-left, 1 = bottom-right). Default (0.5, 0.5) places the gradient at the element center. Ignored for linear gradients.
shapeShape used to interpret _size for radial gradients. Ignored for linear gradients.
sizeExtent of a radial gradient. Ignored for linear gradients.
stopsOrdered list of color stops along the gradient axis.
typeWhether the gradient transitions linearly or radiates from a center point.

Methods

Method

Description

IsEmptyTrue when this gradient has no color stops, meaning it represents "no gradient".

Static Methods

Method

Description

LinearConstruct a linear gradient from an angle (radians) and a stop list.
RadialConstruct a radial gradient at the element center with default extent / shape.