Siddharth-Soni
Siddharth-Soni

Reputation: 120

Problem adding RichTextLabel as child in godot

I tried using add_child and call_deferred, but none of them work.

 extends Control
    var richTextLabel = RichTextLabel.new()
    var rtl = RichTextLabel.new()
    func _ready():
        richTextLabel.set_name("rich")
        richTextLabel.set_use_bbcode(true) 
        richTextLabel.set_bbcode("BBCode [color=blue]blue[/color]")
        richTextLabel.set_position(Vector2(0,0))
        richTextLabel.set_visible_characters(-1)

        rtl.add_text("Hello")
        rtl.set_visible_characters(-1)
        addNodes(rtl, richTextLabel)

    func addNodes(rtl: RichTextLabel, richTextLabel: RichTextLabel):
        self.add_child(rtl)
        self.call_deferred("add_child", richTextLabel)

What am I missing?

Upvotes: 2

Views: 613

Answers (1)

Kis Levente Lorand
Kis Levente Lorand

Reputation: 26

I think the labels are there they are just not visible since you did not position or define a size for them.

Try setting a size and check if they show up:

rtl.set_size(Vector2(100, 100))
richTextLabel.set_size(Vector2(100, 100))

Upvotes: 1

Related Questions