diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index db68168e7ea..e33b02cd81e 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1560,8 +1560,10 @@ void ScriptEditorDebugger::_clear_execution() { stack_script.unref(); } -void ScriptEditorDebugger::start() { - stop(); +void ScriptEditorDebugger::start(int p_port, const IP_Address &p_bind_address) { + if (is_inside_tree()) { + stop(); + } if (is_visible_in_tree()) { EditorNode::get_singleton()->make_bottom_panel_item_visible(this); @@ -1573,7 +1575,11 @@ void ScriptEditorDebugger::start() { } const int max_tries = 6; - remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + if (p_port < 0) { + remote_port = (int)EditorSettings::get_singleton()->get("network/debug/remote_port"); + } else { + remote_port = p_port; + } int current_try = 0; // Find first available port. Error err = server->listen(remote_port); @@ -1582,7 +1588,7 @@ void ScriptEditorDebugger::start() { current_try++; remote_port++; OS::get_singleton()->delay_usec(1000); - err = server->listen(remote_port); + err = server->listen(remote_port, p_bind_address); } // No suitable port found. if (err != OK) { @@ -1592,7 +1598,7 @@ void ScriptEditorDebugger::start() { EditorNode::get_singleton()->get_scene_tree_dock()->show_tab_buttons(); auto_switch_remote_scene_tree = (bool)EditorSettings::get_singleton()->get("debugger/auto_switch_to_remote_scene_tree"); - if (auto_switch_remote_scene_tree) { + if (is_inside_tree() && auto_switch_remote_scene_tree) { EditorNode::get_singleton()->get_scene_tree_dock()->show_remote_tree(); } diff --git a/editor/script_editor_debugger.h b/editor/script_editor_debugger.h index eb939498ef9..257e19868e4 100644 --- a/editor/script_editor_debugger.h +++ b/editor/script_editor_debugger.h @@ -244,7 +244,7 @@ protected: static void _bind_methods(); public: - void start(); + void start(int p_port = -1, const IP_Address &p_bind_address = IP_Address("*")); void pause(); void unpause(); void stop(); diff --git a/main/main.cpp b/main/main.cpp index 6f97da61723..3d4ef1f3240 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -80,6 +80,7 @@ #include "editor/editor_translation.h" #include "editor/progress_dialog.h" #include "editor/project_manager.h" +#include "editor/script_editor_debugger.h" #ifndef NO_EDITOR_SPLASH #include "main/splash_editor.gen.h" #endif @@ -133,6 +134,7 @@ static OS::ProcessID allow_focus_steal_pid = 0; static bool delta_sync_after_draw = false; #ifdef TOOLS_ENABLED static bool auto_build_solutions = false; +static String debug_server_uri; #endif // Display @@ -257,6 +259,7 @@ void Main::print_help(const char *p_binary) { #ifdef TOOLS_ENABLED OS::get_singleton()->print(" -e, --editor Start the editor instead of running the scene.\n"); OS::get_singleton()->print(" -p, --project-manager Start the project manager, even if a project is auto-detected.\n"); + OS::get_singleton()->print(" --debug-server
Start the editor debug server (