How can I update a Button text in the editor with the value from the exported variable in the inspector?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By codevanya

Suppose I have a Button node. I attached a script like this to it:

tool
extends Button

export(String) var num

var _init():
    self.set_text(num)

Now, I want the button text to be updated in the editor automatically as I update the exported variable in the inspector (either instantly or after I save the scene). The above script is not working for me. I guess the value in the exported variable is not yet available when _init() is called.

Beats me. I find no mention of init in the room documentation. Did your code work if you put it into ready or process functions?

StopNot | 2021-07-04 19:07

:bust_in_silhouette: Reply From: Wakatta
tool
extends Button

export(String) var num

var _process(_delta):
    self.set_text(num)