TextBlock
TextBlock is the UIBlock for rendering text.
TextBlocks use TextMeshPro to generate the underlying text-meshes and supports all features exposed on the TextMeshPro
component with a few additions:
- Integration with the layout system, providing specific features such as shrink-to-text.
- Ensures proper render order with other UIBlocks.
- Adds additional rendering features, such as clipping, lighting, and Anti-Aliasing.
Warning
The margin on the TextMeshPro component, as well as the anchor values (e.g. anchorMin and anchorMax) on the RectTransform are controlled by Nova and should not be modified. The same functionality can be accomplished by using the layout system.
Note
TextBlocks use a modified version of the TextMeshPro/Mobile/Distance Field
shader to render, meaning TextMeshPro features exclusively supported through other TextMeshPro shaders (or custom shaders) are currently not supported by TextBlocks.
Autosizing
Shrink to Text
A TextBlock's size can be configured to match that of its rendered text size along the X
and/or Y
axis by using the Autosize.Shrink layout feature.
If a TextBlock is set to shrink on the X
axis, there are two possible configurations, depending on the maximum width specified by the SizeMinMax of the TextBlock:
Configuration | Behaviour |
---|---|
Clamped Wrap | The width of the TextBlock will grow to up to the maximum width, after which the text will wrap |
No-Wrap | The text will not wrap and the Size of the TextBlock will grow indefinitely with the width of the text |
uiBlock.AutoSize.X = AutoSize.Shrink;
uiBlock.AutoSize.Y = AutoSize.Shrink;
Warning
WordWrapping
must be disabled on the TextMeshPro
component when a TextBlock is set to shrink along the X
axis, otherwise the text may end up as a single, vertical column of characters.
Anti-Aliasing
Super-Sampling
TextBlocks support super-sampling, which can drastically improve visual quality in VR scenarios. Super-sampling can be enabled in the project setting Nova > Rendering > Super Sample Text
.
Lit Surfaces
Surface
As with all other UIBlocks, TextBlocks supports Lit Surfaces. See Lighting for more info.