You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Update the edit scene root in time after it is replaced
When changing the type of the edited scene root node, it may be necessary to update edited scene root in time for the child nodes to work properly.
This commit is contained in:
@@ -3430,10 +3430,12 @@ void EditorNode::_remove_scene(int index, bool p_change_tab) {
|
||||
}
|
||||
|
||||
void EditorNode::set_edited_scene(Node *p_scene) {
|
||||
if (get_editor_data().get_edited_scene_root()) {
|
||||
if (get_editor_data().get_edited_scene_root()->get_parent() == scene_root) {
|
||||
scene_root->remove_child(get_editor_data().get_edited_scene_root());
|
||||
Node *old_edited_scene_root = get_editor_data().get_edited_scene_root();
|
||||
if (old_edited_scene_root) {
|
||||
if (old_edited_scene_root->get_parent() == scene_root) {
|
||||
scene_root->remove_child(old_edited_scene_root);
|
||||
}
|
||||
old_edited_scene_root->disconnect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
}
|
||||
get_editor_data().set_edited_scene_root(p_scene);
|
||||
|
||||
@@ -3449,6 +3451,7 @@ void EditorNode::set_edited_scene(Node *p_scene) {
|
||||
if (p_scene->get_parent() != scene_root) {
|
||||
scene_root->add_child(p_scene, true);
|
||||
}
|
||||
p_scene->connect(SNAME("replacing_by"), callable_mp(this, &EditorNode::set_edited_scene));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user