Tuesday, March 19, 2019

2. RichTextLabel

We create a RichTextLabel node using code and set its anchor, margin and text.


We set the text as Hello World!!! and underline the letters.


In project settings, we set window size as 200 by 50.


This script is attached to Node


extends Node

var rtl = RichTextLabel.new()

func _ready():
    rtl.anchor_right = 1
    rtl.anchor_bottom = 1
    rtl.margin_left = 50
    rtl.margin_top = 15
    rtl.margin_right = -50
    rtl.margin_bottom = -15
    rtl.bbcode_enabled = true
    rtl.bbcode_text = "[u]Hello world[/u]!!!"
    add_child(rtl)

The output is a label with the text 'Hello World!!!':


No comments:

Post a Comment