Skip to main content

Element

The Element Component is used to build user interfaces made up of 2D components such as images and text when in a hierarchy with a Screen Component ancestor. The Element Component provides layout properties such as anchors and a pivot point.

See the User Interface section for more details.

Group Element

The group element provides just the layout properties of the Element Component.

Group Element

Image Element

The image element displays an image using a texture asset, sprite asset, or a solid color.

Image Element

Text Element

The text element renders a string of text using a font asset.

Text Element

Common Component Properties

PropertyDescription
TypeThe type of Element: Group, Image, or Text.
PresetChoosing a layout preset will automatically set the Anchor and Pivot properties to a preset value.
AnchorDetermines where the element calculates its position in relation to. See the Elements#Anchor section for more information.
PivotDetermines where the pivot point of the Element is. (0, 0) is bottom left, (1, 1) is top right. See the Elements#Pivot section for more information.
Auto WidthText only. If enabled, the element's width will be automatically calculated based on the text content.
Auto Fit WidthText only. If enabled, the font size will be automatically reduced to fit the text within the element's width.
WidthThe width of the Element in pixels. May be disabled when Auto Width is enabled or when the anchor is horizontally split.
Auto HeightText only. If enabled, the element's height will be automatically calculated based on the text content.
Auto Fit HeightText only. If enabled, the font size will be automatically reduced to fit the text within the element's height.
HeightThe height of the Element in pixels. May be disabled when Auto Height is enabled or when the anchor is vertically split.
MarginThe distance from the edge of the element to the Anchor. This is only available when the Anchor is split (non-equal in one axis). Specified as left, bottom, right, top.
Use InputIf enabled, this Element is added to the list of elements that check for input and fire input related events.
Batch GroupThe Batch Group that this element belongs to. More on Batching here.
LayersThe Layers to render this element into. More on Layers here.

Image Component Properties

PropertyDescription
ColorThe color to tint the element.
OpacityThe transparency of the element, from 0 (fully transparent) to 1 (fully opaque).
RectDefines the area of the texture asset to display, specified as U, V, Width, Height in normalized coordinates. Only shown when using a Texture.
MaskSwitch Image Element into a mask. Masks do not render into the scene, but instead limit child elements to only be rendered where this element is rendered.
TextureThe texture asset to display. Either a Texture, Sprite, or Material can be assigned, but not multiple.
SpriteThe sprite asset to display. Either a Texture, Sprite, or Material can be assigned, but not multiple.
FrameThe sprite frame index to display. Only shown when a Sprite is assigned.
Pixels Per UnitThe number of pixels that correspond to one unit in the component's coordinate system. Only shown when a Sprite is assigned.
MaterialA custom material asset to use for rendering. Either a Texture, Sprite, or Material can be assigned, but not multiple.
Fit ModeHow the image should be fitted within the element bounds. Options are: Stretch (default), Contain (maintain aspect ratio, fit inside), Cover (maintain aspect ratio, fill). Only shown when a Texture or Sprite is assigned.

Text Component Properties

PropertyDescription
AlignmentDetermines how the text is aligned within the element. (0, 0) is bottom left, (1, 1) is top right.
FontThe font asset to use for rendering text.
LocalizedIf enabled, the text will be looked up from the localization data using the Key property.
TextThe text string to display. Only shown when Localized is disabled.
KeyThe localization key used to look up the translated text. Only shown when Localized is enabled.
Enable MarkupIf enabled, the text can contain markup tags for styling (e.g., color, bold).
Font SizeThe size in Screen Component pixels to render the font at. Only shown when Auto Fit Width and Auto Fit Height are disabled.
Min Font SizeThe minimum font size when using Auto Fit Width or Auto Fit Height.
Max Font SizeThe maximum font size when using Auto Fit Width or Auto Fit Height.
Line HeightThe size in Screen Component pixels to move down for a new line.
Wrap LinesIf enabled, text that overflows the width of the text element will be wrapped to the next line.
Max LinesThe maximum number of lines to display. Text beyond this limit will be clipped. Only shown when Wrap Lines is enabled.
SpacingA multiplier to apply to the amount of space between each character.
ColorThe color to tint the font.
OpacityThe transparency of the element, from 0 (fully transparent) to 1 (fully opaque).
Outline ColorThe color of the text outline, including alpha for opacity.
Outline ThicknessThe thickness of the text outline, from 0 (no outline) to 1 (maximum thickness).
Shadow ColorThe color of the text shadow, including alpha for opacity.
Shadow OffsetThe offset of the text shadow from the text, specified as horizontal and vertical offset.

See Also

Scripting Interface

You can control an Element Component's properties using a Script Component. The Element Component's scripting interface is here.