0 votes

Hey guys, so the thing goes like this:

I'm creating an app that generates a UI (mostly buttons) out of a .json file.
These buttons are created using a TextureButton that has a Label as a child.
When I create the button, I update the Label text like this:

func create_button(button_name, button_parent):
var button = button_template.instance()
button.show()
button.get_node("Label").text = str(button_name)
button.name = str(button_name) + "Button"
container.call_deferred("add_child", button)
print(button_parent.name)
if "button_children" in button_parent:
    button.hide()
    button_parent.button_children.append(button)
else:
    first_breadcrumb.button_children.append(button)
connect_signal(button, null, button_parent)
unpack_data(pepito, button)

Notice the button.getnode("Label").text = str(buttonname) line

The thing is, the first time I use button.show() function in the app, the text in the Label doesn't look good. As soon as I reload the scene, the text corrects itself.

Attaching a video and some images that also show the scene setup for the button.

https://youtu.be/8a9VnADHOz0

https://imgur.com/a/iozyhH9

Does anybody know why this happens? And if there's a way to fix it?

asked Jan 13 in Engine by BauRawson (24 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.