From 106bf9b7936e91c50df803158afdf50d1e28c775 Mon Sep 17 00:00:00 2001 From: smix8 <52464204+smix8@users.noreply.github.com> Date: Thu, 2 Jun 2022 10:55:19 +0200 Subject: [PATCH] Add NavigationMesh debug when navmesh is added later through scripts Add NavigationMesh debug when navmesh is added later through scripts (cherry picked from commit b6eff47bac0a2745da6e3aa95ffa340eb71c7248) --- scene/3d/navigation_mesh_instance.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scene/3d/navigation_mesh_instance.cpp b/scene/3d/navigation_mesh_instance.cpp index 0092aa4d530..eff89ef679d 100644 --- a/scene/3d/navigation_mesh_instance.cpp +++ b/scene/3d/navigation_mesh_instance.cpp @@ -139,6 +139,17 @@ void NavigationMeshInstance::set_navigation_mesh(const Ref &p_na NavigationServer::get_singleton()->region_set_navmesh(region, p_navmesh); + if (debug_view == nullptr && is_inside_tree() && navmesh.is_valid() && get_tree()->is_debugging_navigation_hint()) { + MeshInstance *dm = memnew(MeshInstance); + dm->set_mesh(navmesh->get_debug_mesh()); + if (is_enabled()) { + dm->set_material_override(get_tree()->get_debug_navigation_material()); + } else { + dm->set_material_override(get_tree()->get_debug_navigation_disabled_material()); + } + add_child(dm); + debug_view = dm; + } if (debug_view && navmesh.is_valid()) { Object::cast_to(debug_view)->set_mesh(navmesh->get_debug_mesh()); }