Technical Details

Unity’s AI Navigation package does support runtime navmesh baking internally, but it exposes only a very low-level API. There is no editor tooling, no service layer, and no practical workflow for most teams.

The Runtime NavMesh Baker wraps these APIs in a structured, service-based system with intuitive inspectors, menu items, events, and samples—so designers, programmers, and technical artists can all configure runtime baking without writing custom infrastructure.


Core Features

Coordinator-First Workflow

  • The BakerCoordinator component is the main entry point.

  • Owns a NavMeshBakeProfile (asset with all settings) and a Center Target (e.g., player or camera).

  • Automatically attaches and manages the underlying NavMeshBakerService.

Service-Based Architecture

  • NavMeshBakerService manages:

    • Dirty queueing and async bake scheduling.

    • Continuous AABB baking or Grid-Cell streaming.

    • Agent expansion, seam link building, and concurrency control.

  • Normally hidden from end users—accessed via the Coordinator.

Dynamic Surfaces

  • DynamicNavMeshSurface wraps Unity’s NavMeshSurface.

  • Registers automatically with the Coordinator (optional auto-register).

  • Provides buttons to mark itself dirty, register/unregister, and ping its surface.

Profiles

  • NavMeshBakeProfile ScriptableObjects hold all bake parameters:

    • Bake mode (Continuous, Grid Cells, Combined).

    • Bounds sizes, cell dimensions, hysteresis, and rebake intervals.

    • Agent types, default area, and area costs.

    • Concurrency limits and seam-link options.

  • Multiple profiles can be created and swapped quickly.

Event Hooks

  • BakerEvents exposes static events:

    • OnBakeStarted, OnBakeCompleted, OnBakeFailed.

    • OnCombinedBakeStarted, OnCombinedBakeCompleted.

  • Ideal for gameplay hooks (e.g., spawning AI when the navmesh is ready).

Seamless AI Integration

  • Works directly with Unity’s built-in NavMeshAgent, NavMeshQuery, and NavMesh.SamplePosition.

  • Agents automatically re-path when new bakes complete.

Non-Destructive Workflow

  • Combine static editor-baked navmeshes with runtime baking.

  • Useful for hybrid projects: static base levels + procedural/dynamic zones.


System Architecture (At a Glance)

[ Unity NavMesh System (AI Navigation package) ]

        │ (low-level runtime APIs: NavMeshData, UpdateNavMeshDataAsync)

[ NavMeshBakerService ]
    - Centralized runtime baking logic
    - Manages DynamicNavMeshSurfaces
    - Async scheduling, dirty queues, perf metrics
    - Dispatches BakerEvents


[ BakerCoordinator (MonoBehaviour) ]
    - Primary entry point for users
    - Owns NavMeshBakeProfile + Center Target
    - Auto-registers child DynamicNavMeshSurfaces
    - Provides friendly methods: StartBaking, BakeAllNow, EnqueueGridCells


[ Inspector & Editor Tooling ]
    - Quick Setup menu, asset creators, Bake Monitor window
    - Dynamic Surface inspector (mark dirty, register/unregister)

This layered design separates the runtime engine (Service) from the editor/user entry points (Coordinator, inspectors, menus), making it both production-ready and approachable.


Dependencies

  • Unity 2022.3 LTS or newer

  • AI Navigation (com.unity.ai.navigation) – required core package.

Optional / samples only:

  • TextMesh Pro – used in sample UIs.

  • Cinemachine – used in sample scenes for player camera control.

Last updated