Module components_ui_text
UI component that renders text on a canvas using a bank font.
Info:
- Author: Sharper Dev
Functions
| Text:new (gameObject) | Creates an enabled text component using the default font. |
| Text:setCanvas (canvas) | Adds this component to a canvas, removing it from its previous canvas if set. |
| Text:setContent (content) | Stores the text as lines, omitting empty lines. |
| Text:getContent () | Returns the current text content. |
| Text:setFont (fontID) | Selects the font ID used to look up a font in the fonts bank. |
| Text:setLineBreakDistance (value) | Sets the vertical distance added after each rendered line. |
| Text:render () | Draws the text when the component, canvas, and game object are enabled. |
| Text:destroy () | Removes this text component from its canvas. |
Functions
- Text:new (gameObject)
-
Creates an enabled text component using the default font.
Parameters:
- gameObject table Game object that owns this component.
Returns:
-
table The new Text component.
Usage:
local text = gameObject:addComponent("Text")
- Text:setCanvas (canvas)
-
Adds this component to a canvas, removing it from its previous canvas if set.
Parameters:
- canvas table Canvas on which to render the text.
Returns:
-
table This text component.
Usage:
myText:setCanvas(canvas) - Text:setContent (content)
-
Stores the text as lines, omitting empty lines.
Parameters:
- content string Text content to render.
Returns:
-
table This text component.
Usage:
myText:setContent("Hello, World!")
- Text:getContent ()
-
Returns the current text content.
Returns:
-
string Current content.
Usage:
local content = myText:getContent()
- Text:setFont (fontID)
-
Selects the font ID used to look up a font in the fonts bank.
Parameters:
- fontID string Font ID.
Returns:
-
table This text component.
Usage:
myText:setFont("ComicSans")
- Text:setLineBreakDistance (value)
-
Sets the vertical distance added after each rendered line.
Parameters:
- value number Vertical line spacing.
Returns:
-
table This text component.
Usage:
myText:setLineBreakDistance(10)
- Text:render ()
- Draws the text when the component, canvas, and game object are enabled.
- Text:destroy ()
- Removes this text component from its canvas.