MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / load_scene

Method load_scene

editor/editor_node.cpp:4366–4539  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4364}
4365
4366Error EditorNode::load_scene(const String &p_scene, bool p_ignore_broken_deps, bool p_set_inherited, bool p_force_open_imported, bool p_silent_change_tab) {
4367 if (!is_inside_tree()) {
4368 defer_load_scene = p_scene;
4369 return OK;
4370 }
4371
4372 String lpath = ProjectSettings::get_singleton()->localize_path(ResourceUID::ensure_path(p_scene));
4373 _update_prev_closed_scenes(lpath, false);
4374
4375 if (!p_set_inherited) {
4376 for (int i = 0; i < editor_data.get_edited_scene_count(); i++) {
4377 if (editor_data.get_scene_path(i) == lpath) {
4378 _set_current_scene(i);
4379 return OK;
4380 }
4381 }
4382
4383 if (!p_force_open_imported && FileAccess::exists(lpath + ".import")) {
4384 open_imported->set_text(vformat(TTR("Scene '%s' was automatically imported, so it can't be modified.\nTo make changes to it, a new inherited scene can be created."), lpath.get_file()));
4385 open_imported->popup_centered();
4386 new_inherited_button->grab_focus();
4387 open_import_request = lpath;
4388 return OK;
4389 }
4390 }
4391
4392 if (!lpath.begins_with("res://")) {
4393 show_accept(TTR("Error loading scene, it must be inside the project path. Use 'Import' to open the scene, then save it inside the project path."), TTR("OK"));
4394 return ERR_FILE_NOT_FOUND;
4395 }
4396
4397 int prev = editor_data.get_edited_scene();
4398 int idx = prev;
4399
4400 if (prev == -1 || editor_data.get_edited_scene_root() || !editor_data.get_scene_path(prev).is_empty()) {
4401 idx = editor_data.add_edited_scene(-1);
4402
4403 if (p_silent_change_tab) {
4404 _set_current_scene_nocheck(idx);
4405 } else {
4406 _set_current_scene(idx);
4407 }
4408 } else {
4409 EditorUndoRedoManager::get_singleton()->clear_history(editor_data.get_current_edited_scene_history_id(), false);
4410 }
4411
4412 dependency_errors.clear();
4413
4414 Error err;
4415 Ref<PackedScene> sdata = ResourceLoader::load(lpath, "", ResourceFormatLoader::CACHE_MODE_REPLACE, &err);
4416
4417 if (!p_ignore_broken_deps && dependency_errors.has(lpath)) {
4418 current_menu_option = -1;
4419 Vector<String> errors;
4420 for (const String &E : dependency_errors[lpath]) {
4421 errors.push_back(E);
4422 }
4423 dependency_error->show(lpath, errors);

Callers 11

main.cppFile · 0.80
open_scene_from_pathMethod · 0.80
_perform_drop_dataMethod · 0.80
_cell_button_pressedMethod · 0.80
finish_upgradeMethod · 0.80
_lookup_symbolMethod · 0.80
_load_requestMethod · 0.80

Calls 15

vformatFunction · 0.85
TTRFunction · 0.85
hasFunction · 0.85
localize_pathMethod · 0.80
popup_centeredMethod · 0.80
begins_withMethod · 0.80
add_edited_sceneMethod · 0.80
remove_sceneMethod · 0.80
replace_stateMethod · 0.80

Tested by

no test coverage detected