From 999ad9c0a81021ccb4a1e08c46df895fb579f38e Mon Sep 17 00:00:00 2001 From: Nathan Warden Date: Wed, 18 Oct 2017 19:30:27 -0500 Subject: [PATCH] Added a node_added signal to the SceneTree --- scene/main/node.cpp | 2 ++ scene/main/scene_tree.cpp | 7 +++++++ scene/main/scene_tree.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index c2a31b4a8bd..cee25b53a1b 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -212,6 +212,8 @@ void Node::_propagate_enter_tree() { emit_signal(SceneStringNames::get_singleton()->tree_entered); + data.tree->node_added(this); + data.blocked++; //block while adding children diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 7a28e2a6f89..0dadf7443f9 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -85,6 +85,11 @@ void SceneTree::tree_changed() { emit_signal(tree_changed_name); } +void SceneTree::node_added(Node *p_node) { + + emit_signal(node_added_name, p_node); +} + void SceneTree::node_removed(Node *p_node) { if (current_scene == p_node) { @@ -2189,6 +2194,7 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("_server_disconnected"), &SceneTree::_server_disconnected); ADD_SIGNAL(MethodInfo("tree_changed")); + ADD_SIGNAL(MethodInfo("node_added", PropertyInfo(Variant::OBJECT, "node"))); ADD_SIGNAL(MethodInfo("node_removed", PropertyInfo(Variant::OBJECT, "node"))); ADD_SIGNAL(MethodInfo("screen_resized")); ADD_SIGNAL(MethodInfo("node_configuration_warning_changed", PropertyInfo(Variant::OBJECT, "node"))); @@ -2260,6 +2266,7 @@ SceneTree::SceneTree() { root = NULL; current_frame = 0; tree_changed_name = "tree_changed"; + node_added_name = "node_added"; node_removed_name = "node_removed"; ugc_locked = false; call_lock = 0; diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index f3e689adabd..16ac9c67f6b 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -124,6 +124,7 @@ private: bool input_handled; Size2 last_screen_size; StringName tree_changed_name; + StringName node_added_name; StringName node_removed_name; int64_t current_frame; @@ -233,6 +234,7 @@ private: void _rpc(Node *p_from, int p_to, bool p_unreliable, bool p_set, const StringName &p_name, const Variant **p_arg, int p_argcount); void tree_changed(); + void node_added(Node *p_node); void node_removed(Node *p_node); Group *add_to_group(const StringName &p_group, Node *p_node);