Version: Unity 7.0 Alpha (7000.0)
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.
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961