NavMeshBakerService

Internal Runtime Manager for Dynamic Navmesh Baking

The NavMeshBakerService is the internal runtime manager for procedural and dynamic baking. It is owned by the BakerCoordinator and there should only be one instance at runtime.

The Baker Coordinator will add one automatically if it does not exist. Optionally add to the same GameObject as the Baker Coordinator (or click the 'Add Service Component' button on the Baker Coordinator)

Overview

  • Central scheduler for async baking jobs

  • Manages all DynamicNavMeshSurface components

  • Coalesces dirty regions, throttles concurrency, and avoids redundant work

  • Profile-driven via NavMeshBakeProfile

  • Follows a Center Target to keep navigation data relevant

Bake Modes

  • Continuous AABB Maintains a moving bounding box centered on the target. Re-bakes as the target moves beyond thresholds.

  • Grid Cells Divides the world into cells and keeps a configurable ring of cells baked around the target.

Event Hooks

  • OnBakeStarted(DynamicNavMeshSurface, Bounds)

  • OnBakeCompleted(DynamicNavMeshSurface, Bounds, float durationSeconds)

  • OnBakeFailed(DynamicNavMeshSurface, Bounds, string reason)

Inspector (Service)

Although usually hidden behind the Coordinator, the service inspector exposes:

  • Bake Profile

  • Center Target

  • Enable Logs

  • Draw Gizmos

Buttons

  • Set Center = Main Camera

  • Create Profile

  • Open Profile

  • Enqueue (mode-aware)

    • Continuous AABB: Enqueue a bounding-box bake around the target

    • Grid Cells: Enqueue the active cell and ring

  • Enqueue Bake All Surfaces

  • Clear All NavMeshes (Editor-only)

Runtime Status

  • Registered Surfaces

  • Dirty Queue size

  • In-Flight Jobs

  • Skipped(no-src)

  • p95 timings for Update / Collect / Schedule (via GetPerfSnapshot)

Public API (Service)

  • SetCenterTarget(Transform t)

  • RegisterSurface(DynamicNavMeshSurface s)

  • UnregisterSurface(DynamicNavMeshSurface s)

  • MarkDirty(DynamicNavMeshSurface s, Bounds? region, int agentTypeId, int priority)

  • EnqueueBakeAroundTarget()

  • EnqueueCurrentGridCells()

  • EnqueueBakeAllSurfaces()

Best Practices

  • Choose Continuous AABB for compact worlds, Grid Cells for large/procedural maps

  • Keep concurrency balanced to avoid CPU spikes

  • Ensure surfaces contribute valid NavMeshBuildSources to prevent Skipped(no-src)

  • Use Draw Gizmos to visualize volumes and job activity during tuning

Last updated