Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | RazorSh4rk |
I might be overlooking something, but when i instance a scene containing a button, that button doesnt register clicks. On its own the button scene works and i can emit signals from its _ready function, but once i instance it from code neither the signal, nor the simple buttonclick callback doesnt run, and the button doesnt take the “pressed” texture.
Button scene setup:
→ Node2d
… → Button
Button scene script:
extends Node2D
signal _animal_button_pressed(name)
func _on_Button_pressed():
emit_signal("_animal_button_pressed", animal_name)
Game script:
var button = load("res://Scenes/AnimalButton.tscn").instance()
button.connect("_animal_button_pressed", self, "_on_animal_button_pressed")
...
func _on_animal_button_pressed(name):
print(name)
Seems like adding a child to a Node2D or a Control, so that
->Node2D | Control
…->Node2D
…->Button
Doesnt work? Added the buttons to the scene root and they work perfectly but i have no idea why.
RazorSh4rk | 2020-05-21 00:25