TextRenderer:GetFont, TextRenderer:SetFontEdit

[Font] TextRenderer:GetFont()
TextRenderer:SetFont( [Font] font to use )

Gets or sets the font used by the text renderer to draw text.

You can get a font asset to use with CS.FindAsset( "path to font asset", "Font" )

TextRenderer:GetText, TextRenderer:SetTextEdit

[string] TextRenderer:GetText()
TextRenderer:SetText( [string] text to display )

Gets or sets the text to draw.

Example: Draw a counterEdit

-- Assuming we have a TextTenderer component on our object

function Behavior:Awake()
    self.counter = 0

​function Behavior:Update()
    self.counter = self.counter + 1
    self.gameObject.textRenderer:SetText( "Counter: " .. self.counter )

TextRenderer:GetAlignment, TextRenderer:SetAlignmentEdit

[TextRenderer.Alignment] TextRenderer:GetAlignment()
TextRenderer:SetAlignment( [TextRenderer.Alignment] alignment )

Gets or sets how the text should be aligned. Possible values are:

  • TextRenderer.Alignment.Left (default)
  • TextRenderer.Alignment.Center
  • TextRenderer.Alignment.Right


[number] TextRenderer:GetTextWidth( [string] text to measure=nil )

Returns the length (in scene units) of the specified text as it would be drawn by the text renderer. If you don't specify any text to measure, the current text currently displayed by the TextRenderer is used.

TextRenderer:GetOpacity, TextRenderer:SetOpacityEdit

[number] TextRenderer:GetOpacity()
TextRenderer:SetOpacity( [number] opacity )

Gets or sets the text renderer's opacity (between 0.0 and 1.0)