Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Node name to print() of all Nodes by making to_string() in Object virtual, so it can be overriden in C++. #38819

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<SceneState> &p_state) {
data.instance_state = p_state;
}
Expand Down
2 changes: 2 additions & 0 deletions scene/main/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down