Skip to main content

Editor.Components.Text

Class

Renders and manages text in the scene with customizable font, size, layout, and visual effects.

Index

Example

const model = this.pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
const scene = model.project.scene;

const obj = scene.createSceneObject('TextObj');
const text = obj.addComponent('Text') as Editor.Components.Text;

text.text = 'Hello World';
text.size = 48;
text.italic = false;
text.depthTest = false;
text.letterSpacing = 0.0;

Extends

Properties

advancedLayout

advancedLayout: TextAdvancedLayout

Advanced layout configuration for text rendering.


backgroundSettings

backgroundSettings: BackgroundSettings

Background appearance settings for the text.


capitalizationOverride

capitalizationOverride: CapitalizationOverride

Override text capitalization style.


customMaterial

customMaterial: Material

A custom Material to render this Text with, authored from a Mesh3d shader graph that uses the Text Data node. The material must have a single Pass; if it is invalid (unsupported shader or more than one Pass) or null (the default), Text renders with the built-in text shader.


debugRenderLayoutRect

debugRenderLayoutRect: boolean

If enabled, draws the Text.layoutRect bounds as a wireframe for debugging text layout. Has no effect when a Editor.Components.ScreenTransform is attached to the same SceneObject, since the ScreenTransform supersedes the layoutRect.


depthTest

depthTest: boolean

Enable or disable depth testing for text rendering.


dropshadowSettings

dropshadowSettings: DropshadowSettings

Drop shadow effect settings for the text.


editable

editable: boolean

Enable or disable text editing in preview mode.


enabled

enabled: boolean

Whether the component is active.

Inherited from

BaseMeshVisual.enabled


enableRichText

enableRichText: boolean

If enabled, inputted text will be interpreted as rich text.


font

font: Font

Font asset used for rendering text.


fontSource

fontSource: Font | FontCollection | FontFamily

The font source for this text component. Can be a Font, FontFamily, or FontCollection asset.


hasPrefabChanges

readonly hasPrefabChanges: boolean

Whether this entity differs from its counterpart in the prefab or was added to the prefab instance. Always false outside prefab instances.

Inherited from

BaseMeshVisual.hasPrefabChanges


horizontalAlignment

horizontalAlignment: Horizontal

Horizontal alignment of the mesh visual.

Inherited from

BaseMeshVisual.horizontalAlignment


horizontalOverflow

horizontalOverflow: HorizontalOverflow

Behavior when text exceeds horizontal bounds.


id

readonly id: Uuid

The unique id of the entity.

Inherited from

BaseMeshVisual.id


isPrefabInstanceRoot

readonly isPrefabInstanceRoot: boolean

Whether this entity is the root of a prefab instance.

Inherited from

BaseMeshVisual.isPrefabInstanceRoot


italic?

optional italic?: boolean

Enable or disable italic text styling.


layoutRect

layoutRect: Rect

The rectangular bounds the text is laid out within. Controls text wrapping and alignment, and defines the area Text.horizontalOverflow, Text.verticalOverflow, and Text.sizeToFit are evaluated against. Each bound is defined as an offset in world units from the SceneObject's position. If a Editor.Components.ScreenTransform is attached to the same SceneObject, it always supersedes this property text is laid out within the ScreenTransform's rect instead, and changes to layoutRect have no effect.


letterSpacing

letterSpacing: number

Spacing between individual characters.


lineSpacing

lineSpacing: number

Spacing between text lines.


meshShadowMode

meshShadowMode: MeshShadowMode

Shadow rendering mode for the mesh.

Inherited from

BaseMeshVisual.meshShadowMode


meta

readonly meta: Meta

Metadata associated with this entity, providing access to its unique identifier and other descriptive properties.

Inherited from

BaseMeshVisual.meta


name

name: string

Name of the component.

Inherited from

BaseMeshVisual.name


outlineSettings

outlineSettings: OutlineSettings

Text outline effect settings.


preferredStyle

preferredStyle: string

Controls style applied to the text. Accepts a Editor.Components.FontStyles constant (e.g. FontStyles.Bold). If Text.fontSource is assigned to a variable font or a font collection with variable fonts, this also accepts a named instance name or custom variation style name that belongs to the variable font. Matching is case-insensitive and ignores whitespace and hyphens, so "Bold Italic", "bolditalic", and "bold-italic" all resolve to the same style. If Text.weight or Text.italic are explicitly assigned, they will override any weight or italic axis value in preferredStyle.


renderOrder

renderOrder: number

Determines the order in which this visual component is rendered relative to others.

Inherited from

BaseMeshVisual.renderOrder


sceneObject

readonly sceneObject: SceneObject

Scene object this component is attached to.

Inherited from

BaseMeshVisual.sceneObject


shadowColor

shadowColor: vec4

Color of the mesh shadow.

Inherited from

BaseMeshVisual.shadowColor


shadowDensity

shadowDensity: number

Opacity of the mesh shadow.

Inherited from

BaseMeshVisual.shadowDensity


showEditingPreview

showEditingPreview: boolean

Show the text editing preview in the editor.


size

size: number

Font size in units.


sizeToFit

sizeToFit: boolean

Automatically scale text to fit bounds.


stretchMode

stretchMode: StretchMode

How the mesh stretches to fit its container.

Inherited from

BaseMeshVisual.stretchMode


text

text: string

The text string to render.


textFill

textFill: TextFill

Text color and fill settings.


touchHandler

touchHandler: InteractionComponent

Enable or disable touch interaction for text.


twoSided

twoSided: boolean

Render text on both sides of the plane.


type

readonly type: string

The entity's type.

Inherited from

BaseMeshVisual.type


verticalAlignment

verticalAlignment: Vertical

Vertical alignment of the mesh visual.

Inherited from

BaseMeshVisual.verticalAlignment


verticalOverflow

verticalOverflow: VerticalOverflow

Behavior when text exceeds vertical bounds.


weight?

optional weight?: number

Font weight value.

Methods

getDirectlyReferencedEntities()

getDirectlyReferencedEntities(): Entity[]

A list of entities which this entity has a reference to.

Returns

Entity[]

Inherited from

BaseMeshVisual.getDirectlyReferencedEntities


getMeta()

static getMeta(): Meta

Returns metadata about this type.

Returns

Meta

Overrides

BaseMeshVisual.getMeta


getOwnedEntities()

getOwnedEntities(): Entity[]

A list of entities which has a reference to this entity.

Returns

Entity[]

Inherited from

BaseMeshVisual.getOwnedEntities


getPrefabInstanceRoot()

getPrefabInstanceRoot(): Prefabable

Returns the nearest prefab instance root that contains this entity, starting with the entity itself, or null if it is not part of a prefab instance.

Returns

Prefabable

Inherited from

BaseMeshVisual.getPrefabInstanceRoot


getTypeName()

static getTypeName(): string

Returns the type name of this class.

Returns

string

Overrides

BaseMeshVisual.getTypeName


getTypeName()

getTypeName(): string

Returns the name of this object's type.

Returns

string

Inherited from

BaseMeshVisual.getTypeName


isOfType()

isOfType(type): boolean

Returns true if the object is of the specified type.

Parameters

ParameterType
typestring

Returns

boolean

Inherited from

BaseMeshVisual.isOfType


isSame()

isSame(other): boolean

Returns true if this object refers to the same instance as the given object.

Parameters

ParameterType
otherScriptObject

Returns

boolean

Inherited from

BaseMeshVisual.isSame