Godot v4.2.1
extends CanvasLayer
signal finished_adding_texts
@onready var container = %TextContainer
@onready var scroll = %Scroll
const TEXT_CONTAINER = preload("res://_Scenes/Core/Balloon/history_text.tscn")
var history : Array = []
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS
get_tree().paused = true
connect("finished_adding_texts", handle_scrollbar_changed)
func add_texts():
if history.size() > 0:
for i in history.size():
print(str(i))
var instance = TEXT_CONTAINER.instantiate()
instance.text = history[i]
container.add_child(instance)
emit_signal("finished_adding_texts")
func set_texts(texts : Array):
history = texts
func _process(_delta):
if Input.is_action_pressed("esc"):
get_tree().paused = false
self.queue_free()
func _on_close_pressed():
get_tree().paused = false
self.queue_free()
var handle_scrollbar_changed = func():
var scrollbar = scroll.get_v_scroll_bar()
scrollbar.value = scrollbar.max_value

I’m making a visual novel, and every time a text passes it gets stored inside the history array. When I click a button a history panel opens, its a scene consisting of a scroll container, a vbox container and dynamically created labels inside the vbox container.
Everything works fine, but the thing is that when I open the history window the scrollbar stays at the start, and I want it to drop down to the last text added automatically. I want it down when the labels are all in place, and not everytime a label appears.
I tried with the code I attached and it just not works.