1
0
mirror of https://github.com/godotengine/godot.git synced 2025-12-03 16:55:53 +00:00

Adds "Set as Main Scene" option to EditorSceneTabs context menu

Adds the option to quickly set main scene by right-clicking a scene tab. If the scene has no root, then the option is greyed out. If the scene is unsaved, the file is saved and then set as main scene.

Co-Authored-By: Alex Tam <65537185+altamkp@users.noreply.github.com>
This commit is contained in:
vaner-org
2025-05-29 03:57:17 +05:30
parent bd2ca13c6f
commit 8aea5136f8
3 changed files with 27 additions and 1 deletions

View File

@@ -2600,6 +2600,11 @@ void EditorNode::_dialog_action(String p_file) {
}
} break;
case SAVE_AND_SET_MAIN_SCENE: {
_save_scene(p_file);
_menu_option_confirm(SCENE_SET_MAIN_SCENE, true);
} break;
case FILE_EXPORT_MESH_LIBRARY: {
const Dictionary &fd_options = file_export_lib->get_selected_options();
bool merge_with_existing_library = fd_options.get(TTR("Merge With Existing"), true);
@@ -3332,6 +3337,19 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) {
} break;
case SCENE_SET_MAIN_SCENE: {
const String scene_path = editor_data.get_scene_path(editor_data.get_edited_scene());
if (scene_path.is_empty()) {
current_menu_option = SAVE_AND_SET_MAIN_SCENE;
_menu_option_confirm(SCENE_SAVE_AS_SCENE, true);
file->set_title(TTR("Save new main scene..."));
} else {
ProjectSettings::get_singleton()->set("application/run/main_scene", ResourceUID::path_to_uid(scene_path));
ProjectSettings::get_singleton()->save();
FileSystemDock::get_singleton()->update_all();
}
} break;
case SCENE_SAVE_ALL_SCENES: {
_save_all_scenes();
} break;