You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Fix get_path() error when calling get_node()
This commit is contained in:
@@ -1341,12 +1341,23 @@ Node *Node::get_node(const NodePath &p_path) const {
|
|||||||
Node *node = get_node_or_null(p_path);
|
Node *node = get_node_or_null(p_path);
|
||||||
|
|
||||||
if (unlikely(!node)) {
|
if (unlikely(!node)) {
|
||||||
|
// Try to get a clear description of this node in the error message.
|
||||||
|
String desc;
|
||||||
|
if (is_inside_tree()) {
|
||||||
|
desc = get_path();
|
||||||
|
} else {
|
||||||
|
desc = get_name();
|
||||||
|
if (desc.is_empty()) {
|
||||||
|
desc = get_class();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p_path.is_absolute()) {
|
if (p_path.is_absolute()) {
|
||||||
ERR_FAIL_V_MSG(nullptr,
|
ERR_FAIL_V_MSG(nullptr,
|
||||||
vformat(R"(Node not found: "%s" (absolute path attempted from "%s").)", p_path, get_path()));
|
vformat(R"(Node not found: "%s" (absolute path attempted from "%s").)", p_path, desc));
|
||||||
} else {
|
} else {
|
||||||
ERR_FAIL_V_MSG(nullptr,
|
ERR_FAIL_V_MSG(nullptr,
|
||||||
vformat(R"(Node not found: "%s" (relative to "%s").)", p_path, get_path()));
|
vformat(R"(Node not found: "%s" (relative to "%s").)", p_path, desc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user