| 6513 | } |
| 6514 | |
| 6515 | void EditorNode::reload_scene(const String &p_path) { |
| 6516 | int scene_idx = -1; |
| 6517 | |
| 6518 | String lpath = ProjectSettings::get_singleton()->localize_path(p_path); |
| 6519 | |
| 6520 | for (int i = 0; i < editor_data.get_edited_scene_count(); i++) { |
| 6521 | if (editor_data.get_scene_path(i) == lpath) { |
| 6522 | scene_idx = i; |
| 6523 | break; |
| 6524 | } |
| 6525 | } |
| 6526 | |
| 6527 | int current_tab = editor_data.get_edited_scene(); |
| 6528 | |
| 6529 | if (scene_idx == -1) { |
| 6530 | if (get_edited_scene()) { |
| 6531 | int current_history_id = editor_data.get_current_edited_scene_history_id(); |
| 6532 | bool is_unsaved = EditorUndoRedoManager::get_singleton()->is_history_unsaved(current_history_id); |
| 6533 | |
| 6534 | // Scene is not open, so at it might be instantiated. We'll refresh the whole scene later. |
| 6535 | EditorUndoRedoManager::get_singleton()->clear_history(current_history_id, false); |
| 6536 | if (is_unsaved) { |
| 6537 | EditorUndoRedoManager::get_singleton()->set_history_as_unsaved(current_history_id); |
| 6538 | } |
| 6539 | } |
| 6540 | return; |
| 6541 | } |
| 6542 | |
| 6543 | if (current_tab == scene_idx) { |
| 6544 | editor_data.apply_changes_in_editors(); |
| 6545 | _save_editor_states(p_path); |
| 6546 | } |
| 6547 | |
| 6548 | // Reload scene. |
| 6549 | _remove_scene(scene_idx, false); |
| 6550 | load_scene(p_path, true, false, true); |
| 6551 | |
| 6552 | // Adjust index so tab is back a the previous position. |
| 6553 | editor_data.move_edited_scene_to_index(scene_idx); |
| 6554 | EditorUndoRedoManager::get_singleton()->clear_history(editor_data.get_scene_history_id(scene_idx), false); |
| 6555 | |
| 6556 | // Recover the tab. |
| 6557 | scene_tabs->set_current_tab(current_tab); |
| 6558 | } |
| 6559 | |
| 6560 | void EditorNode::find_all_instances_inheriting_path_in_node(Node *p_root, Node *p_node, const String &p_instance_path, HashSet<Node *> &p_instance_list) { |
| 6561 | String scene_file_path = p_node->get_scene_file_path(); |
no test coverage detected