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
- Type: Struct
- Namespace: UnityEngine.UIElements
- Assembly: UnityEngine.UIElementsModule
- Implements: IEquatable<BackgroundGradient>
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 |
|---|---|
| angle | Angle of a linear gradient, in radians, measured clockwise from "to top" (CSS convention, matching |
| position | Center 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. |
| shape | Shape used to interpret _size for radial gradients. Ignored for linear gradients. |
| size | Extent of a radial gradient. Ignored for linear gradients. |
| stops | Ordered list of color stops along the gradient axis. |
| type | Whether the gradient transitions linearly or radiates from a center point. |
Methods
Method | Description |
|---|---|
| IsEmpty | True when this gradient has no color stops, meaning it represents "no gradient". |