Fix _notification with parent and child classes

This commit is contained in:
David Snopek
2024-02-02 10:07:45 -06:00
parent f90085917b
commit 23c010900c
6 changed files with 62 additions and 2 deletions

View File

@@ -245,6 +245,14 @@ func _ready():
assert_equal(example.test_virtual_implemented_in_script("Virtual", 939), "Implemented")
assert_equal(custom_signal_emitted, ["Virtual", 939])
# Test that notifications happen on both parent and child classes.
var example_child = $ExampleChild
assert_equal(example_child.get_value1(), 11)
assert_equal(example_child.get_value2(), 33)
example_child.notification(NOTIFICATION_ENTER_TREE, true)
assert_equal(example_child.get_value1(), 11)
assert_equal(example_child.get_value2(), 22)
exit_with_status()
func _on_Example_custom_signal(signal_name, value):

View File

@@ -24,4 +24,6 @@ offset_right = 79.0
offset_bottom = 29.0
text = "Click me!"
[node name="ExampleChild" type="ExampleChild" parent="."]
[connection signal="custom_signal" from="Example" to="." method="_on_Example_custom_signal"]