diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index 070b98f21d9e..c2e7e1faa24a 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -222,6 +222,10 @@ If [code]true[/code], collision shapes will be visible when running the game from the editor for debugging purposes. [b]Note:[/b] This property is not designed to be changed at run-time. Changing the value of [member debug_collisions_hint] while the project is running will not have the desired effect. + + If [code]true[/code], Marker2D and Marker3D nodes will be visible when running the game from the editor for debugging purposes. + [b]Note:[/b] This property is not designed to be changed at run-time. Changing the value of [member debug_markers_hint] while the project is running will not have the desired effect. + If [code]true[/code], navigation polygons will be visible when running the game from the editor for debugging purposes. [b]Note:[/b] This property is not designed to be changed at run-time. Changing the value of [member debug_navigation_hint] while the project is running will not have the desired effect. diff --git a/editor/editor_run.cpp b/editor/editor_run.cpp index 99c8481d3354..2cdf0ab9402e 100644 --- a/editor/editor_run.cpp +++ b/editor/editor_run.cpp @@ -66,6 +66,7 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) { bool debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisions", false); bool debug_paths = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_paths", false); bool debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false); + bool debug_markers = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_markers", false); if (debug_collisions) { args.push_back("--debug-collisions"); } @@ -78,6 +79,10 @@ Error EditorRun::run(const String &p_scene, const String &p_write_movie) { args.push_back("--debug-navigation"); } + if (debug_markers) { + args.push_back("--debug-markers"); + } + if (p_write_movie != "") { args.push_back("--write-movie"); args.push_back(p_write_movie); diff --git a/editor/editor_run_native.cpp b/editor/editor_run_native.cpp index 47a9661bcb5c..ffd24e83f7ec 100644 --- a/editor/editor_run_native.cpp +++ b/editor/editor_run_native.cpp @@ -136,6 +136,7 @@ Error EditorRunNative::run_native(int p_idx, int p_platform) { bool deploy_dumb = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_file_server", false); bool debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisions", false); bool debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false); + bool debug_markers = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_markers", false); if (deploy_debug_remote) { flags |= EditorExportPlatform::DEBUG_FLAG_REMOTE_DEBUG; @@ -149,6 +150,9 @@ Error EditorRunNative::run_native(int p_idx, int p_platform) { if (debug_navigation) { flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_NAVIGATION; } + if (debug_markers) { + flags |= EditorExportPlatform::DEBUG_FLAG_VIEW_MARKERS; + } eep->clear_messages(); Error err = eep->run(preset, p_idx, flags); diff --git a/editor/export/editor_export_platform.cpp b/editor/export/editor_export_platform.cpp index c86114a140c6..f2d66c23485c 100644 --- a/editor/export/editor_export_platform.cpp +++ b/editor/export/editor_export_platform.cpp @@ -183,6 +183,10 @@ void EditorExportPlatform::gen_debug_flags(Vector &r_flags, int p_flags) if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { r_flags.push_back("--debug-navigation"); } + + if (p_flags & DEBUG_FLAG_VIEW_MARKERS) { + r_flags.push_back("--debug-markers"); + } } Error EditorExportPlatform::_save_pack_file(void *p_userdata, const String &p_path, const Vector &p_data, int p_file, int p_total, const Vector &p_enc_in_filters, const Vector &p_enc_ex_filters, const Vector &p_key) { @@ -1616,6 +1620,10 @@ void EditorExportPlatform::gen_export_flags(Vector &r_flags, int p_flags if (p_flags & DEBUG_FLAG_VIEW_NAVIGATION) { r_flags.push_back("--debug-navigation"); } + + if (p_flags & DEBUG_FLAG_VIEW_MARKERS) { + r_flags.push_back("--debug-markers"); + } } bool EditorExportPlatform::can_export(const Ref &p_preset, String &r_error, bool &r_missing_templates) const { diff --git a/editor/export/editor_export_platform.h b/editor/export/editor_export_platform.h index 88dc7bd5cd15..8f7ce05a336c 100644 --- a/editor/export/editor_export_platform.h +++ b/editor/export/editor_export_platform.h @@ -212,6 +212,7 @@ class EditorExportPlatform : public RefCounted { DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST = 4, DEBUG_FLAG_VIEW_COLLISIONS = 8, DEBUG_FLAG_VIEW_NAVIGATION = 16, + DEBUG_FLAG_VIEW_MARKERS = 32, }; virtual Error run(const Ref &p_preset, int p_device, int p_debug_flags) { return OK; } diff --git a/editor/plugins/debugger_editor_plugin.cpp b/editor/plugins/debugger_editor_plugin.cpp index dd6187c2649c..7463bd1f0781 100644 --- a/editor/plugins/debugger_editor_plugin.cpp +++ b/editor/plugins/debugger_editor_plugin.cpp @@ -78,6 +78,9 @@ DebuggerEditorPlugin::DebuggerEditorPlugin(PopupMenu *p_debug_menu) { debug_menu->add_check_shortcut(ED_SHORTCUT("editor/visible_navigation", TTR("Visible Navigation")), RUN_DEBUG_NAVIGATION); debug_menu->set_item_tooltip(-1, TTR("When this option is enabled, navigation meshes and polygons will be visible in the running project.")); + debug_menu->add_check_shortcut(ED_SHORTCUT("editor/visible_markers", TTR("Visible Markers")), RUN_DEBUG_MARKERS); + debug_menu->set_item_tooltip(-1, + TTR("When this option is enabled, Marker2D and Marker3D nodes will be visible in the running project.")); debug_menu->add_separator(); debug_menu->add_check_shortcut(ED_SHORTCUT("editor/sync_scene_changes", TTR("Synchronize Scene Changes")), RUN_LIVE_DEBUG); debug_menu->set_item_tooltip(-1, @@ -167,6 +170,12 @@ void DebuggerEditorPlugin::_menu_option(int p_option) { debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_NAVIGATION), !ischecked); EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_navigation", !ischecked); + } break; + case RUN_DEBUG_MARKERS: { + bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_DEBUG_MARKERS)); + debug_menu->set_item_checked(debug_menu->get_item_index(RUN_DEBUG_MARKERS), !ischecked); + EditorSettings::get_singleton()->set_project_metadata("debug_options", "run_debug_markers", !ischecked); + } break; case RUN_RELOAD_SCRIPTS: { bool ischecked = debug_menu->is_item_checked(debug_menu->get_item_index(RUN_RELOAD_SCRIPTS)); @@ -193,6 +202,7 @@ void DebuggerEditorPlugin::_update_debug_options() { bool check_debug_collisions = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_collisions", false); bool check_debug_paths = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_paths", false); bool check_debug_navigation = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_navigation", false); + bool check_debug_markers = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_markers", false); bool check_live_debug = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_live_debug", true); bool check_reload_scripts = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_reload_scripts", true); int instances = EditorSettings::get_singleton()->get_project_metadata("debug_options", "run_debug_instances", 1); @@ -212,6 +222,9 @@ void DebuggerEditorPlugin::_update_debug_options() { if (check_debug_navigation) { _menu_option(RUN_DEBUG_NAVIGATION); } + if (check_debug_markers) { + _menu_option(RUN_DEBUG_MARKERS); + } if (check_live_debug) { _menu_option(RUN_LIVE_DEBUG); } diff --git a/editor/plugins/debugger_editor_plugin.h b/editor/plugins/debugger_editor_plugin.h index c706acdb5c07..f006c40ed4eb 100644 --- a/editor/plugins/debugger_editor_plugin.h +++ b/editor/plugins/debugger_editor_plugin.h @@ -51,6 +51,7 @@ class DebuggerEditorPlugin : public EditorPlugin { RUN_DEBUG_COLLISIONS, RUN_DEBUG_PATHS, RUN_DEBUG_NAVIGATION, + RUN_DEBUG_MARKERS, RUN_DEPLOY_REMOTE_DEBUG, RUN_RELOAD_SCRIPTS, }; diff --git a/main/main.cpp b/main/main.cpp index 28a73ce58563..2f589f6cd430 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -191,6 +191,7 @@ static bool use_debug_profiler = false; static bool debug_collisions = false; static bool debug_paths = false; static bool debug_navigation = false; +static bool debug_markers = false; #endif static int frame_delay = 0; static bool disable_render_loop = false; @@ -391,6 +392,7 @@ void Main::print_help(const char *p_binary) { OS::get_singleton()->print(" --debug-collisions Show collision shapes when running the scene.\n"); OS::get_singleton()->print(" --debug-paths Show path lines when running the scene.\n"); OS::get_singleton()->print(" --debug-navigation Show navigation polygons when running the scene.\n"); + OS::get_singleton()->print(" --debug-markers Show Marker2D and Marker3D nodes when running the scene.\n"); OS::get_singleton()->print(" --debug-stringnames Print all StringName allocations to stdout when the engine quits.\n"); #endif OS::get_singleton()->print(" --frame-delay Simulate high CPU load (delay each frame by milliseconds).\n"); @@ -1194,6 +1196,8 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph debug_paths = true; } else if (I->get() == "--debug-navigation") { debug_navigation = true; + } else if (I->get() == "--debug-markers") { + debug_markers = true; } else if (I->get() == "--debug-stringnames") { StringName::set_debug_stringnames(true); #endif @@ -2677,6 +2681,9 @@ bool Main::start() { NavigationServer3D::get_singleton()->set_active(true); NavigationServer3D::get_singleton_mut()->set_debug_enabled(true); } + if (debug_markers) { + sml->set_debug_markers_hint(true); + } #endif bool embed_subwindows = GLOBAL_DEF("display/window/subwindows/embed_subwindows", true); diff --git a/misc/dist/shell/_godot.zsh-completion b/misc/dist/shell/_godot.zsh-completion index 2bc6fe93176b..c6695acda1f2 100644 --- a/misc/dist/shell/_godot.zsh-completion +++ b/misc/dist/shell/_godot.zsh-completion @@ -67,6 +67,7 @@ _arguments \ '--remote-debug[enable remote debugging]:remote debugger address' \ '--debug-collisions[show collision shapes when running the scene]' \ '--debug-navigation[show navigation polygons when running the scene]' \ + '--debug-markers[show Marker2D and Marker3D nodes when running the scene]' \ '--debug-stringnames[print all StringName allocations to stdout when the engine quits]' \ '--frame-delay[simulate high CPU load (delay each frame by the given number of milliseconds)]:number of milliseconds' \ '--time-scale[force time scale (higher values are faster, 1.0 is normal speed)]:time scale' \ diff --git a/misc/dist/shell/godot.bash-completion b/misc/dist/shell/godot.bash-completion index bc5fa600f5fa..3abcde908f00 100644 --- a/misc/dist/shell/godot.bash-completion +++ b/misc/dist/shell/godot.bash-completion @@ -69,6 +69,7 @@ _complete_godot_options() { --remote-debug --debug-collisions --debug-navigation +--debug-markers --debug-stringnames --frame-delay --time-scale diff --git a/misc/dist/shell/godot.fish b/misc/dist/shell/godot.fish index 9ac692eace29..2861df8d432e 100644 --- a/misc/dist/shell/godot.fish +++ b/misc/dist/shell/godot.fish @@ -87,6 +87,7 @@ complete -c godot -l gpu-abort -d "Abort on graphics API usage errors (usually v complete -c godot -l remote-debug -d "Enable remote debugging" complete -c godot -l debug-collisions -d "Show collision shapes when running the scene" complete -c godot -l debug-navigation -d "Show navigation polygons when running the scene" +complete -c godot -l debug-markers -d "Show Marker2D and Marker3D nodes when running the scene" complete -c godot -l debug-stringnames -d "Print all StringName allocations to stdout when the engine quits" complete -c godot -l frame-delay -d "Simulate high CPU load (delay each frame by the given number of milliseconds)" -x complete -c godot -l time-scale -d "Force time scale (higher values are faster, 1.0 is normal speed)" -x diff --git a/scene/2d/marker_2d.cpp b/scene/2d/marker_2d.cpp index d203c58ffd98..c684a8138f7c 100644 --- a/scene/2d/marker_2d.cpp +++ b/scene/2d/marker_2d.cpp @@ -93,7 +93,7 @@ void Marker2D::_notification(int p_what) { if (!is_inside_tree()) { break; } - if (Engine::get_singleton()->is_editor_hint()) { + if (Engine::get_singleton()->is_editor_hint() || get_tree()->is_debugging_markers_hint()) { _draw_cross(); } } break; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 3f71de1b183a..faf8a4cca2c1 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -688,6 +688,14 @@ void SceneTree::set_debug_navigation_hint(bool p_enabled) { bool SceneTree::is_debugging_navigation_hint() const { return debug_navigation_hint; } + +void SceneTree::set_debug_markers_hint(bool p_enabled) { + debug_markers_hint = p_enabled; +} + +bool SceneTree::is_debugging_markers_hint() const { + return debug_markers_hint; +} #endif void SceneTree::set_debug_collisions_color(const Color &p_color) { @@ -1217,6 +1225,8 @@ void SceneTree::_bind_methods() { ClassDB::bind_method(D_METHOD("is_debugging_paths_hint"), &SceneTree::is_debugging_paths_hint); ClassDB::bind_method(D_METHOD("set_debug_navigation_hint", "enable"), &SceneTree::set_debug_navigation_hint); ClassDB::bind_method(D_METHOD("is_debugging_navigation_hint"), &SceneTree::is_debugging_navigation_hint); + ClassDB::bind_method(D_METHOD("set_debug_markers_hint", "enable"), &SceneTree::set_debug_markers_hint); + ClassDB::bind_method(D_METHOD("is_debugging_markers_hint"), &SceneTree::is_debugging_markers_hint); ClassDB::bind_method(D_METHOD("set_edited_scene_root", "scene"), &SceneTree::set_edited_scene_root); ClassDB::bind_method(D_METHOD("get_edited_scene_root"), &SceneTree::get_edited_scene_root); @@ -1278,6 +1288,7 @@ void SceneTree::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_collisions_hint"), "set_debug_collisions_hint", "is_debugging_collisions_hint"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_paths_hint"), "set_debug_paths_hint", "is_debugging_paths_hint"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_navigation_hint"), "set_debug_navigation_hint", "is_debugging_navigation_hint"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "debug_markers_hint"), "set_debug_markers_hint", "is_debugging_markers_hint"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_pause", "is_paused"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "edited_scene_root", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_edited_scene_root", "get_edited_scene_root"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "current_scene", PROPERTY_HINT_RESOURCE_TYPE, "Node", PROPERTY_USAGE_NONE), "set_current_scene", "get_current_scene"); diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index a460e40597e3..0335f31e196d 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -103,6 +103,7 @@ class SceneTree : public MainLoop { bool debug_collisions_hint = false; bool debug_paths_hint = false; bool debug_navigation_hint = false; + bool debug_markers_hint = false; #endif bool paused = false; int root_lock = 0; @@ -311,6 +312,9 @@ class SceneTree : public MainLoop { void set_debug_navigation_hint(bool p_enabled); bool is_debugging_navigation_hint() const; + + void set_debug_markers_hint(bool p_enabled); + bool is_debugging_markers_hint() const; #else void set_debug_collisions_hint(bool p_enabled) {} bool is_debugging_collisions_hint() const { return false; } @@ -320,6 +324,9 @@ class SceneTree : public MainLoop { void set_debug_navigation_hint(bool p_enabled) {} bool is_debugging_navigation_hint() const { return false; } + + void set_debug_markers_hint(bool p_enabled) {} + bool is_debugging_markers_hint() const { return false; } #endif void set_debug_collisions_color(const Color &p_color);