TextStyle
live Describes the visual style of a text label, including font size, color, weight, decoration, alignment, and font asset.
Constructor
TextStyle
live Describes the visual style of a text label, including font size, color, weight, decoration, alignment, and font asset.
| Parameter | Description |
|---|---|
FontSize | The font size in logical pixels. Null inherits from the parent. |
Color | The text color. Null inherits from the parent. |
Bold | Whether the text is bold. |
Italic | Whether the text is italic. |
Underline | Whether the text is underlined. |
LetterSpacing | Additional spacing between characters in logical pixels. |
LineHeight | Line height as a multiplier of the font size. Null uses the default. |
TextAlign | Horizontal and vertical text alignment within the label bounds. Null inherits from the parent. Maps to style.unityTextAlign. |
FontAsset | SDF font asset for rendering. Null falls back to FontFamily, then Unity’s default. Maps to style.unityFontDefinition via FontDefinition.FromSDFFont. |
ResetPadding | When true, zeroes out the UIToolkit Label’s built-in padding and margin. Use when the label is inside a flex container that handles its own centering, to prevent intrinsic Label padding from offsetting the visual result. |
Properties
Bold
Whether the text is bold.
Color
The text color. Null inherits from the parent.
FontAsset
SDF font asset for rendering. Null falls back to FontFamily, then Unity’s default. Maps to style.unityFontDefinition via FontDefinition.FromSDFFont.
FontSize
The font size in logical pixels. Null inherits from the parent.
Inherit
A text style with no overrides, inheriting all values from the parent.
Italic
Whether the text is italic.
LetterSpacing
Additional spacing between characters in logical pixels.
LineHeight
Line height as a multiplier of the font size. Null uses the default.
ResetPadding
When true, zeroes out the UIToolkit Label’s built-in padding and margin. Use when the label is inside a flex container that handles its own centering, to prevent intrinsic Label padding from offsetting the visual result.
TextAlign
Horizontal and vertical text alignment within the label bounds. Null inherits from the parent. Maps to style.unityTextAlign.
Underline
Whether the text is underlined.
Methods
AsBold
Returns a copy of this style with Bold set to true.
AsItalic
Returns a copy of this style with Italic set to true.
AsUnderlined
Returns a copy of this style with Underline set to true.
WithColor
Returns a copy of this style with the given Color.
| Parameter | Description |
|---|---|
color | The text color. |
WithLetterSpacing
Returns a copy of this style with the given LetterSpacing.
| Parameter | Description |
|---|---|
spacing | Additional spacing between characters in logical pixels. |
WithLineHeight
Returns a copy of this style with the given LineHeight.
| Parameter | Description |
|---|---|
lineHeight | Line height as a multiplier of the font size. |
WithSize
Returns a copy of this style with the given FontSize.
| Parameter | Description |
|---|---|
size | The font size in logical pixels. |