Merge pull request #112746 from Kaleb-Reid/show-nodepath-subnames

Show NodePath subnames in editor inspector
This commit is contained in:
Thaddeus Crews 2026-01-28 17:58:22 -06:00
commit d4ab136b24
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
2 changed files with 18 additions and 4 deletions

View file

@ -2029,9 +2029,14 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path,
// Try to find the target node in modified node paths.
HashMap<Node *, NodePath>::Iterator found_node_path = p_renames->find(target_node);
if (found_node_path) {
String old_subnames;
if (r_node_path.get_subname_count() > 0) {
old_subnames = ":" + r_node_path.get_concatenated_subnames();
}
HashMap<Node *, NodePath>::Iterator found_root_path = p_renames->find(p_root_node);
NodePath root_path_new = found_root_path ? found_root_path->value : p_root_node->get_path();
r_node_path = root_path_new.rel_path_to(found_node_path->value);
r_node_path = NodePath(String(root_path_new.rel_path_to(found_node_path->value)) + old_subnames);
return true;
}
@ -2041,9 +2046,14 @@ bool SceneTreeDock::_update_node_path(Node *p_root_node, NodePath &r_node_path,
if (found_root_path) {
NodePath root_path_new = found_root_path->value;
if (!root_path_new.is_empty()) {
String old_subnames;
if (r_node_path.get_subname_count() > 0) {
old_subnames = ":" + r_node_path.get_concatenated_subnames();
}
NodePath old_abs_path = NodePath(String(p_root_node->get_path()).path_join(String(r_node_path)));
old_abs_path.simplify();
r_node_path = root_path_new.rel_path_to(old_abs_path);
r_node_path = NodePath(String(root_path_new.rel_path_to(old_abs_path)) + old_subnames);
}
return true;

View file

@ -3172,13 +3172,17 @@ void EditorPropertyNodePath::update_property() {
const Node *target_node = base_node->get_node(p);
ERR_FAIL_NULL(target_node);
if (String(target_node->get_name()).contains_char('@')) {
String new_text = target_node->get_name();
if (new_text.contains_char('@')) {
assign->set_button_icon(Ref<Texture2D>());
assign->set_text(String(p));
return;
}
assign->set_text(target_node->get_name());
if (p.get_subname_count() > 0) {
new_text += ":" + p.get_concatenated_subnames();
}
assign->set_text(new_text);
assign->set_button_icon(EditorNode::get_singleton()->get_object_icon(target_node));
}