From 3ca25ffe8a8b2726cd959b20efe1a4066c75a6b6 Mon Sep 17 00:00:00 2001 From: Eric M Date: Mon, 12 Jul 2021 00:40:18 +1000 Subject: [PATCH] Added Node name to print() when printing Nodes. --- scene/main/node.cpp | 12 ++++++++++++ scene/main/node.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/scene/main/node.cpp b/scene/main/node.cpp index ef6d2e72f6b7..233288ebfaf3 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1822,6 +1822,18 @@ Node *Node::get_deepest_editable_node(Node *p_start_node) const { return node; } +String Node::to_string() { + if (get_script_instance()) { + bool valid; + String ret = get_script_instance()->to_string(&valid); + if (valid) { + return ret; + } + } + + return (get_name() ? String(get_name()) + ":" : "") + Object::to_string(); +} + void Node::set_scene_instance_state(const Ref &p_state) { data.instance_state = p_state; } diff --git a/scene/main/node.h b/scene/main/node.h index fc5af43829ca..95a982087404 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -329,6 +329,8 @@ class Node : public Object { bool is_editable_instance(const Node *p_node) const; Node *get_deepest_editable_node(Node *p_start_node) const; + virtual String to_string() override; + /* NOTIFICATIONS */ void propagate_notification(int p_notification);