diff --git a/Source/Engine/Navigation/NavMesh.h b/Source/Engine/Navigation/NavMesh.h index bd0eab703..f1a901967 100644 --- a/Source/Engine/Navigation/NavMesh.h +++ b/Source/Engine/Navigation/NavMesh.h @@ -34,6 +34,15 @@ public: /// AssetReference DataAsset; +#if USE_EDITOR + + /// + /// If checked, the navmesh will be drawn in debug view when showing navigation data. + /// + API_FIELD(Attributes="EditorOrder(-10), EditorDisplay(\"Nav Mesh\")") bool ShowDebugDraw = true; + +#endif + /// /// The navigation mesh properties. /// diff --git a/Source/Engine/Navigation/Navigation.cpp b/Source/Engine/Navigation/Navigation.cpp index d146e9c1e..7f8ca5e9a 100644 --- a/Source/Engine/Navigation/Navigation.cpp +++ b/Source/Engine/Navigation/Navigation.cpp @@ -8,7 +8,12 @@ #include "Engine/Content/Content.h" #include "Engine/Content/JsonAsset.h" #include "Engine/Threading/Threading.h" +#if USE_EDITOR +#include "Engine/Level/Level.h" #include "Engine/Level/Scene/Scene.h" +#endif +#include "NavMesh.h" + #include "Engine/Engine/EngineService.h" #include "Engine/Profiler/ProfilerCPU.h" #include "Engine/Serialization/Serialization.h" @@ -263,6 +268,27 @@ void Navigation::DrawNavMesh() { for (auto navMesh : NavMeshes) { +#if USE_EDITOR + // Skip drawing if any of the navmeshes on scene has disabled ShowDebugDraw option + bool skip = false; + for (auto scene : Level::Scenes) + { + for (auto e : scene->NavigationMeshes) + { + if (e->Properties == navMesh->Properties) + { + if (!e->ShowDebugDraw) + { + skip = true; + } + break; + } + } + } + if (skip) + continue; +#endif + navMesh->DebugDraw(); } }