Version: Unity 6.7 Alpha (6000.7)
LanguageEnglish
  • C#

BackgroundGradient

struct in UnityEngine.UIElements

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Color gradient that can be used as a Background, mirroring the CSS linear-gradient() / radial-gradient() functions.

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 linear-gradient(0deg, ...)). Ignored for radial gradients.
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.
shapeShape used to interpret BackgroundGradient.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.

Public 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.