Godot - Adding Text to a RichTextLabel
This is a GDScript code example for adding text to a RichTextLabel.
This method is not available for Label nodes.
When you want to add new text to the existing text in a RichTextLabel, you can use add_text()
or append_text()
. Use `add_text()
` if the text you want to add is not BBCode text.
var label = RichTextLabel.new()
add_child(label)
label.global_position = Vector2(0, 0)
label.size = Vector2(200,200)
label.text = "Append"
# Adding Text to a RichTextLabel
add_text("Text")
Enable BBCode and use append_text()
to add tagged text.
var label = RichTextLabel.new()
add_child(label)
label.global_position = Vector2(0, 0)
label.size = Vector2(200,200)
label.text = "Append"
# Adding BBCode Text to a RichTextLabel
label.bbcode_enabled = true
append_text("[b]Text[/b]")