Skip to content

Commit 29c2615

Browse files
committed
Remove toggling of unique names in subscenes
1 parent f497156 commit 29c2615

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

editor/gui/scene_tree_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ void SceneTreeEditor::_add_nodes(Node *p_node, TreeItem *p_parent) {
311311
}
312312

313313
if (p_node->is_unique_name_in_owner()) {
314-
item->add_button(0, get_editor_theme_icon(SNAME("SceneUniqueName")), BUTTON_UNIQUE, false, vformat(TTR("This node can be accessed from within anywhere in the scene by preceding it with the '%s' prefix in a node path.\nClick to disable this."), UNIQUE_NODE_PREFIX));
314+
item->add_button(0, get_editor_theme_icon(SNAME("SceneUniqueName")), BUTTON_UNIQUE, p_node->get_owner() != EditorNode::get_singleton()->get_edited_scene(), vformat(TTR("This node can be accessed from within anywhere in the scene by preceding it with the '%s' prefix in a node path.\nClick to disable this."), UNIQUE_NODE_PREFIX));
315315
}
316316

317317
int num_connections = p_node->get_persistent_signal_connection_count();

editor/scene_tree_dock.cpp

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,25 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
11581158
return;
11591159
}
11601160
}
1161-
bool enabling = !first_selected->get()->is_unique_name_in_owner();
11621161

11631162
List<Node *> full_selection = editor_selection->get_full_selected_node_list();
1163+
1164+
// Check if all the nodes for this operation are invalid, and if they are, pop up a dialog and end here.
1165+
bool all_nodes_owner_invalid = true;
1166+
for (Node *node : full_selection) {
1167+
if (node->get_owner() == get_tree()->get_edited_scene_root()) {
1168+
all_nodes_owner_invalid = false;
1169+
break;
1170+
}
1171+
}
1172+
if (all_nodes_owner_invalid) {
1173+
accept->set_text(TTR("Can't toggle unique name for nodes in subscene!"));
1174+
accept->popup_centered();
1175+
return;
1176+
}
1177+
1178+
bool enabling = !first_selected->get()->is_unique_name_in_owner();
1179+
11641180
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
11651181

11661182
if (enabling) {
@@ -1172,6 +1188,10 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
11721188
if (node->is_unique_name_in_owner()) {
11731189
continue;
11741190
}
1191+
if (node->get_owner() != get_tree()->get_edited_scene_root()) {
1192+
continue;
1193+
}
1194+
11751195
StringName name = node->get_name();
11761196
if (new_unique_names.find(name) != -1 || get_tree()->get_edited_scene_root()->get_node_or_null(UNIQUE_NODE_PREFIX + String(name)) != nullptr) {
11771197
cant_be_set_unique_names.push_back(name);
@@ -1205,6 +1225,9 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
12051225
if (!node->is_unique_name_in_owner()) {
12061226
continue;
12071227
}
1228+
if (node->get_owner() != get_tree()->get_edited_scene_root()) {
1229+
continue;
1230+
}
12081231
undo_redo->add_do_method(node, "set_unique_name_in_owner", false);
12091232
undo_redo->add_undo_method(node, "set_unique_name_in_owner", true);
12101233
}

0 commit comments

Comments
 (0)