Reputation: 11
I'm looking to create child objects that are duplicates of a pre-existing, using this method in my root class. While it successfully creates a copy of that object in the remote tree during runtime, it is not sending signals like the original object (for instance, the objects send a signal to a UI component which displays its global position in realtime). How do I create a child object that matches the signals emitted by the original?
func create_Object(Obj, size, position): var New = Obj.instance() add_child(New) New.scale = size New.global_transform.origin = position
Upvotes: 0
Views: 1126
Reputation: 40295
You can enumerate the lists of defined signals of a Node
with get_signal_list
. Example:
var signals = node.get_signal_list()
for cur_signal in signals:
print(cur_signal.name)
You can use get_signal_connection_list
to get the outgoing connections:
var signals = node.get_signal_list()
for cur_signal in signals:
var conns = node.get_signal_connection_list(cur_signal.name)
for cur_conn in conns:
print(cur_conn.signal)
print(cur_conn.target)
print(cur_conn.method)
Then connect them with, well, connect
:
var signals = node.get_signal_list()
for cur_signal in signals:
var conns = node.get_signal_connection_list(cur_signal.name)
for cur_conn in conns:
new_node.connect(cur_conn.signal, cur_conn.target, cur_conn.method)
Upvotes: 0