Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

Prevent overwriting loaded scene state when opening a scene from an empty tab

distmed75d9a9365454
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp
index 851ef0f1c21..d1f0ffd2e90 100644
--- a/editor/editor_node.cpp
+++ b/editor/editor_node.cpp
@@ -5060,13 +5060,15 @@ Error EditorNode::open_scene(const String &p_scene, bool p_ignore_broken_deps, b
}
}
+ bool ignore_state = !editor_data.get_edited_scene_root();
+
RETURN_IF_ERROR(load_scene(p_scene, p_ignore_broken_deps, p_set_inherited, p_force_open_imported));
int current_scene_idx = editor_data.get_edited_scene_count() - 1;
Node *new_scene = editor_data.get_edited_scene_root(current_scene_idx);
ERR_FAIL_NULL_V(new_scene, ERR_BUG);
- _set_current_scene_nocheck(current_scene_idx);
+ _set_current_scene_nocheck(current_scene_idx, ignore_state);
// When editor plugins load in, they might use node transforms during their own setup, so make sure they're up to date.
get_tree()->flush_transform_notifications();