> For the complete documentation index, see [llms.txt](https://megacrush.gitbook.io/megacrush-unity-assets/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://megacrush.gitbook.io/megacrush-unity-assets/runtime-navmesh-baker/runtime-navmesh-baker-user-manual/package-elements/components/dynamic-navmesh-surface.md).

# Dynamic NavMesh Surface

The **DynamicNavMeshSurface** is a wrapper for Unity’s built-in `NavMeshSurface` that integrates with the **Runtime Navmesh Baker** system.

> Add a `DynamicNavmeshSurface` component to every `NavMeshSurface` in your scene to register it with the runtime baker

It acts as the **bakeable unit of geometry**: each surface defines a region that can be collected and baked at runtime.

Unlike a standard `NavMeshSurface`, a `DynamicNavMeshSurface` can:

* Register/unregister itself with the **BakerCoordinator**
* Be marked dirty on demand (triggering re-bakes)
* Show live links to the active Coordinator
* Expose runtime registration controls in Play Mode

***

<figure><img src="/files/5UG2hUqGCMRq7vj94ia5" alt=""><figcaption></figcaption></figure>

### Overview

* **Surface Binding**\
  Wraps and references a `NavMeshSurface` component.
* **Coordinator Integration**\
  Registers itself with the active `BakerCoordinator` (if Auto Register is enabled).
* **Dirty Marking**\
  Surfaces can be marked dirty either locally or around the current Center Target.
* **Runtime Controls**\
  Can be registered/unregistered dynamically at runtime for procedural workflows.
* **One Shot Support (new in 1.4.0)**\
  In One Shot mode, surfaces contribute geometry once at startup or when the one-shot bake is triggered.
  * After the bake, registration state is retained but no rebakes are scheduled automatically.
  * Manual `MarkDirty()` calls are still valid if you want to force a rebake of a changed surface.

***

### Typical Setup

1. Add a `NavMeshSurface` to a GameObject.
2. Add a `DynamicNavMeshSurface` to the same GameObject.
3. In the inspector:
   * Assign the `NavMeshSurface` to the **Surface** field, or click **Assign from this GameObject**.
   * Enable **Auto Register** (recommended) so the surface registers automatically with the Coordinator.
4. Ensure a **BakerCoordinator** exists in the scene with a profile and center target set.
5. At runtime, the surface will be managed automatically by the baking system.

***

### Inspector Reference

#### Core Fields

* **Surface**\
  Reference to a `NavMeshSurface`. Required for baking.
* **Auto Register**\
  If enabled, the surface registers automatically with the active Coordinator on Play.

#### Status Box

* If no surface is assigned:
  * Shows “No NavMeshSurface assigned”
  * Button: **Assign from this GameObject** (tries to auto-bind a `NavMeshSurface`)
* If assigned:
  * Status shows **Ready**
  * Button: **Ping Surface** (highlights the bound `NavMeshSurface` in the Project/Hierarchy)

#### Coordinator Snapshot

Shows the state of the active `BakerCoordinator` in the scene:

* **Coordinator reference**
* **Has Profile** (bool)
* **Center Target reference**

**Actions**

* **Open Coordinator** – Selects and pings the active Coordinator
* **Mark Dirty (Local)** – Marks this surface as dirty, enqueuing a bake for its own bounds
* **Mark Dirty (Around Target)** – Marks this surface dirty for a region around the Coordinator’s Center Target, using the profile’s base bounds size
* If no Coordinator is present, displays **“No active BakerCoordinator found in the scene.”**

#### Runtime Controls *(Play Mode only)*

* **Register Now** – Registers this surface with the Coordinator manually
* **Unregister** – Unregisters this surface from the Coordinator

***

### Public API

```csharp
void MarkDirty(Bounds? region = null);
void Register();
void Unregister();
```

* `MarkDirty()` — Marks this surface as dirty and enqueues a bake for the given region (or its own bounds if null).
* `Register()` / `Unregister()` — Can be called manually, but are usually managed automatically by the Coordinator.

***

### Best Practices

* Always pair a `DynamicNavMeshSurface` with a valid `NavMeshSurface`.
* Use **Auto Register** unless you need explicit runtime control.
* Use **Mark Dirty (Around Target)** for moving targets (e.g., player/camera) to ensure relevant regions are updated.
* Break large worlds into multiple surfaces so only relevant sections need baking.
* In **procedural workflows**, combine with `ProceduralTileManager` to spawn/destroy surfaces dynamically.
* In **One Shot mode**, keep surfaces stable at startup so the bake can succeed. If geometry changes later, call `MarkDirty()` to trigger a manual rebake.
