Skip to content

Commit

Permalink
Fix error reopening non existing scene on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin committed Sep 15, 2024
1 parent 6681f25 commit d06c7ad
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5249,14 +5249,18 @@ void EditorNode::_load_open_scenes_from_config(Ref<ConfigFile> p_layout) {

PackedStringArray scenes = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "open_scenes");
for (int i = 0; i < scenes.size(); i++) {
load_scene(scenes[i]);
if (FileAccess::exists(scenes[i])) {
load_scene(scenes[i]);
}
}

if (p_layout->has_section_key(EDITOR_NODE_CONFIG_SECTION, "current_scene")) {
String current_scene = p_layout->get_value(EDITOR_NODE_CONFIG_SECTION, "current_scene");
int current_scene_idx = scenes.find(current_scene);
if (current_scene_idx >= 0) {
_set_current_scene(current_scene_idx);
for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
if (editor_data.get_scene_path(i) == current_scene) {
_set_current_scene(i);
break;
}
}
}

Expand Down

0 comments on commit d06c7ad

Please sign in to comment.