From 47568a465466bac9607f8df06cb1692cd8b583e9 Mon Sep 17 00:00:00 2001 From: kobewi Date: Sat, 12 Apr 2025 09:15:10 +0200 Subject: [PATCH] Add --scene command line argument --- editor/editor_run.cpp | 1 + main/main.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index f7297d280b..08f74e3dc6 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -146,6 +146,7 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie, const V } if (!p_scene.is_empty()) { + args.push_back("--scene"); args.push_back(p_scene); } diff --git a/main/main.cpp b/main/main.cpp index 25ed1404be..88430f87ec 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -513,7 +513,7 @@ void Main::print_help(const char *p_binary) { print_help_copyright("(c) 2014-present Godot Engine contributors. (c) 2007-present Juan Linietsky, Ariel Manzur."); print_help_title("Usage"); - OS::get_singleton()->print(" %s \u001b[96m[options] [path to scene or \"project.godot\" file]\u001b[0m\n", p_binary); + OS::get_singleton()->print(" %s \u001b[96m[options] [path to \"project.godot\" file]\u001b[0m\n", p_binary); #if defined(TOOLS_ENABLED) print_help_title("Option legend (this build = editor)"); @@ -554,6 +554,7 @@ void Main::print_help(const char *p_binary) { print_help_option("--quit-after ", "Quit after the given number of iterations. Set to 0 to disable.\n"); print_help_option("-l, --language ", "Use a specific locale ( being a two-letter code).\n"); print_help_option("--path ", "Path to a project ( must contain a \"project.godot\" file).\n"); + print_help_option("--scene ", "Path or UID of a scene in the project that should be started.\n"); print_help_option("-u, --upwards", "Scan folders upwards for project.godot file.\n"); print_help_option("--main-pack ", "Path to a pack (.pck) file to load.\n"); #ifdef DISABLE_DEPRECATED @@ -3846,7 +3847,14 @@ int Main::start() { } else if (E->get() == "--install-android-build-template") { install_android_build_template = true; #endif // TOOLS_ENABLED - } else if (E->get().length() && E->get()[0] != '-' && positional_arg.is_empty()) { + } else if (E->get() == "--scene") { + E = E->next(); + if (E) { + game_path = E->get(); + } else { + ERR_FAIL_V_MSG(EXIT_FAILURE, "Missing scene path, aborting."); + } + } else if (E->get().length() && E->get()[0] != '-' && positional_arg.is_empty() && game_path.is_empty()) { positional_arg = E->get(); if (E->get().ends_with(".scn") ||