From e825a6fb01b3f12e7afb066c58a3c8782b21cc3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E9=9D=92=E5=B1=B1?= Date: Thu, 11 Apr 2024 22:29:18 +0800 Subject: [PATCH] Make the inherited scene root node unable to change type Make the inherited scene root behave like other children from the inherited scene. --- editor/scene_tree_dock.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 757b9e72ea1..0b489cbb363 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2079,17 +2079,19 @@ bool SceneTreeDock::_validate_no_foreign() { return false; } - // When edited_scene inherits from another one the root Node will be the parent Scene, - // we don't want to consider that Node a foreign one otherwise we would not be able to - // delete it. - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene == E) { - continue; - } + if (edited_scene->get_scene_inherited_state().is_valid()) { + // When edited_scene inherits from another one the root Node will be the parent Scene, + // we don't want to consider that Node a foreign one otherwise we would not be able to + // delete it. + if (edited_scene == E && current_option != TOOL_REPLACE) { + continue; + } - if (edited_scene->get_scene_inherited_state().is_valid() && edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { - accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); - accept->popup_centered(); - return false; + if (edited_scene == E || edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { + accept->set_text(TTR("Can't operate on nodes the current scene inherits from!")); + accept->popup_centered(); + return false; + } } } @@ -3443,6 +3445,13 @@ void SceneTreeDock::_tree_rmb(const Vector2 &p_menu_pos) { can_replace = false; break; } + + if (edited_scene->get_scene_inherited_state().is_valid()) { + if (E == edited_scene || edited_scene->get_scene_inherited_state()->find_node_by_path(edited_scene->get_path_to(E)) >= 0) { + can_replace = false; + break; + } + } } if (can_replace) {