Hello!
Recently I ran into a problem with my UI-script: There, I add a button and a progressbar to the screen. When the button is pressed, a signal is emitted to another script, wich then runs a function, lets call it "doSomething". Inside this function, a different signal is emitted, to update the progressbar in my UI-script. But this doesn't work at all. Only when the function "doSomething" in the script is finished, it updates the progressbar to 100%. When I print the progress, it shows correct results. Can anybody tell me what to do here?
This is how my code looks:
extends Node
signal doSomething
func _ready():
pass
func _on_main_openMenu():
var button = Button.new()
button.set_text("doSomething")
button.connect("pressed", self, "_button_pressed")
button.anchor_top = 0.5
button.anchor_left = 0.1
add_child(button)
var progressbar = ProgressBar.new()
progressbar.anchor_top = 0.5
progressbar.anchor_left = 0.5
add_child(progressbar)
func _button_pressed():
emit_signal("doSomething")
func _on_otherScript_progress(progress):
print(int(progress*100))
self.progressbar.value = int(progress*100)