Godot Version
4.2.1
Question
Hi there! I would like to ask about best practice of signals. I have 2 nodes in UI, where one of these is trying to disable a button from another one using a signal.
I have a script on the first node:
signal button_disabled(is_disabled)
func set_button_disabled(is_disabled: bool):
resolution_button.disabled = is_disabled
And I have second script on the another node, which is trying to use the signal of the first node (trying to disable a button):
func _ready():
resolution_node.button_disabled.connect(Callable(self, "set_button_disabled"))
func set_test_button_disabled(is_disabled: bool):
resolution_node.set_button_disabled(is_disabled)
I’ve noticed, that I can just type “signal button_disabled” without parameters and everything will work fine. And there I have a few questions:
- Am I calling a signal from another node in the right way?
- Should I use somewhere .emit or emit_signal(…) to call my signal instead of using the name of the function?
- Maybe there is any other best ways to connect nodes using signals? (only in code)
Thank you for your answers!