Class EntityTextComponent
- Namespace
- Stride.CommunityToolkit.Engine
- Assembly
- Stride.CommunityToolkit.dll
Represents a text rendering component that can be attached to an entity to display screen-space text.
public class EntityTextComponent : EntityComponent, IIdentifiable
- Inheritance
-
EntityTextComponent
- Implements
- Inherited Members
Remarks
This component automatically positions text relative to the entity's position in screen space. All color and positional values are managed in RGBA color space and screen pixels respectively.
Constructors
EntityTextComponent()
Initializes a new instance of the EntityTextComponent class.
public EntityTextComponent()
Properties
Alignment
Gets or sets the text alignment relative to the entity's position.
public TextAlignment Alignment { get; set; }
Property Value
- TextAlignment
A TextAlignment enum value. Default is Left.
BackgroundColor
Gets or sets the color of the background behind the text.
public Color4? BackgroundColor { get; set; }
Property Value
EnableBackground
Gets or sets a value indicating whether to use a background behind the text.
public bool EnableBackground { get; set; }
Property Value
FontSize
Gets or sets the size of the font in points.
public float FontSize { get; set; }
Property Value
- float
A positive float value representing font size. Default is 18px.
Offset
Gets or sets the screen-space offset from the entity's position.
public Vector2 Offset { get; set; }
Property Value
- Vector2
A Vector2 representing X/Y offset in pixels. Positive values move text right/up, negative left/down.
Padding
Gets or sets the padding around the text.
public float Padding { get; set; }
Property Value
Position
Gets or sets an optional position of the text in screen space.
public Vector2? Position { get; set; }
Property Value
Text
Gets or sets the text content to be displayed.
public required string Text { get; set; }
Property Value
- string
A non-null string containing the text to render.
TextColor
Gets or sets the color of the rendered text.
public Color TextColor { get; set; }
Property Value
- Color
A Color structure defining the text color. Default is White for better visibility against dark backgrounds.
Methods
Validate()
Validates that the component has valid configuration.
public bool Validate()
Returns
- bool
True if valid; otherwise, false.