diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.cpp b/editor/debugger/debug_adapter/debug_adapter_parser.cpp index e3fcdd9636d..3648f990fc0 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.cpp +++ b/editor/debugger/debug_adapter/debug_adapter_parser.cpp @@ -184,6 +184,20 @@ Dictionary DebugAdapterParser::req_launch(const Dictionary &p_params) const { return Dictionary(); } +Vector DebugAdapterParser::_extract_play_arguments(const Dictionary &p_args) const { + Vector play_args; + if (p_args.has("playArgs")) { + Variant v = p_args["playArgs"]; + if (v.get_type() == Variant::ARRAY) { + Array arr = v; + for (const Variant &arg : arr) { + play_args.push_back(String(arg)); + } + } + } + return play_args; +} + Dictionary DebugAdapterParser::_launch_process(const Dictionary &p_params) const { Dictionary args = p_params["arguments"]; ScriptEditorDebugger *dbg = EditorDebuggerNode::get_singleton()->get_default_debugger(); @@ -193,7 +207,15 @@ Dictionary DebugAdapterParser::_launch_process(const Dictionary &p_params) const String platform_string = args.get("platform", "host"); if (platform_string == "host") { - EditorRunBar::get_singleton()->play_main_scene(); + Vector play_args = _extract_play_arguments(args); + const String scene = args.get("scene", "main"); + if (scene == "main") { + EditorRunBar::get_singleton()->play_main_scene(false, play_args); + } else if (scene == "current") { + EditorRunBar::get_singleton()->play_current_scene(false, play_args); + } else { + EditorRunBar::get_singleton()->play_custom_scene(scene, play_args); + } } else { int device = args.get("device", -1); int idx = -1; diff --git a/editor/debugger/debug_adapter/debug_adapter_parser.h b/editor/debugger/debug_adapter/debug_adapter_parser.h index 5dd139b6a53..73d101ebc5c 100644 --- a/editor/debugger/debug_adapter/debug_adapter_parser.h +++ b/editor/debugger/debug_adapter/debug_adapter_parser.h @@ -85,6 +85,7 @@ public: Dictionary req_godot_put_msg(const Dictionary &p_params) const; // Internal requests + Vector _extract_play_arguments(const Dictionary &p_args) const; Dictionary _launch_process(const Dictionary &p_params) const; // Events diff --git a/editor/run/editor_run_bar.cpp b/editor/run/editor_run_bar.cpp index 0e3e5088c04..655fe5c4e89 100644 --- a/editor/run/editor_run_bar.cpp +++ b/editor/run/editor_run_bar.cpp @@ -375,7 +375,7 @@ void EditorRunBar::recovery_mode_reload_project() { EditorNode::get_singleton()->trigger_menu_option(EditorNode::PROJECT_RELOAD_CURRENT_PROJECT, false); } -void EditorRunBar::play_main_scene(bool p_from_native) { +void EditorRunBar::play_main_scene(bool p_from_native, const Vector &p_play_args) { if (Engine::get_singleton()->is_recovery_mode_hint()) { EditorToaster::get_singleton()->popup_str(TTR("Recovery Mode is enabled. Disable it to run the project."), EditorToaster::SEVERITY_WARNING); return; @@ -387,7 +387,7 @@ void EditorRunBar::play_main_scene(bool p_from_native) { stop_playing(); current_mode = RunMode::RUN_MAIN; - _run_scene(); + _run_scene("", p_play_args); } } @@ -582,7 +582,7 @@ EditorRunBar::EditorRunBar() { play_button->set_toggle_mode(true); play_button->set_focus_mode(Control::FOCUS_ACCESSIBILITY); play_button->set_tooltip_text(TTRC("Run the project's default scene.")); - play_button->connect(SceneStringName(pressed), callable_mp(this, &EditorRunBar::play_main_scene).bind(false)); + play_button->connect(SceneStringName(pressed), callable_mp(this, &EditorRunBar::play_main_scene).bind(false, Vector())); ED_SHORTCUT_AND_COMMAND("editor/run_project", TTRC("Run Project"), Key::F5); ED_SHORTCUT_OVERRIDE("editor/run_project", "macos", KeyModifierMask::META | Key::B); diff --git a/editor/run/editor_run_bar.h b/editor/run/editor_run_bar.h index 36b7f4044ad..6f7376a0f02 100644 --- a/editor/run/editor_run_bar.h +++ b/editor/run/editor_run_bar.h @@ -113,7 +113,7 @@ public: void recovery_mode_show_dialog(); void recovery_mode_reload_project(); - void play_main_scene(bool p_from_native = false); + void play_main_scene(bool p_from_native = false, const Vector &p_play_args = Vector()); void play_current_scene(bool p_reload = false, const Vector &p_play_args = Vector()); void play_custom_scene(const String &p_custom, const Vector &p_play_args = Vector());