Merge pull request #12224 from NathanWarden/scene_tree_added_signal

Added a node_added signal to the SceneTree
This commit is contained in:
Rémi Verschelde 2017-10-20 22:10:47 +02:00 committed by GitHub
commit 067fc88488
3 changed files with 11 additions and 0 deletions

View File

@ -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

View File

@ -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;

View File

@ -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);