Baker Events

The BakerEvents class is a global event hub for runtime baking.

Note: This is not a separate component you need to add — it is built into the system.

It broadcasts when per-surface, combined-window, or one-shot bakes start, complete, or fail. Use these events to trigger gameplay logic after navmesh updates — for example, spawning AI only once a valid navmesh exists.


Available Events

// Per-surface events
event Action<DynamicNavMeshSurface, Bounds> OnBakeStarted;
event Action<DynamicNavMeshSurface, Bounds, float> OnBakeCompleted;
event Action<DynamicNavMeshSurface, Bounds, string> OnBakeFailed;

// Combined-window events
event Action<int, Bounds> OnCombinedBakeStarted;
event Action<int, Bounds, float> OnCombinedBakeCompleted;

// One Shot events (new in 1.4.0)
event Action<int, Bounds> OnOneShotBakeStarted;
event Action<int, Bounds, float> OnOneShotBakeCompleted;
  • OnBakeStarted(DynamicNavMeshSurface surface, Bounds bounds) Raised when a per-surface bake begins. surface may be null in combined or one-shot mode.

  • OnBakeCompleted(DynamicNavMeshSurface surface, Bounds bounds, float seconds) Raised when a per-surface bake finishes successfully. Includes duration in seconds.

  • OnBakeFailed(DynamicNavMeshSurface surface, Bounds bounds, string reason) Raised when a bake is skipped or fails. reason provides a textual cause (e.g. "no sources").

  • OnCombinedBakeStarted(int agentTypeId, Bounds bounds) Raised when a combined-window bake begins for a specific agent type.

  • OnCombinedBakeCompleted(int agentTypeId, Bounds bounds, float seconds) Raised when a combined-window bake completes successfully.

  • OnOneShotBakeStarted(int agentTypeId, Bounds bounds) (new in 1.4.0) Raised when a one-shot bake begins for a given agent type.

  • OnOneShotBakeCompleted(int agentTypeId, Bounds bounds, float seconds) (new in 1.4.0) Raised when a one-shot bake finishes successfully.


Example: Spawn After Bake


Best Practices

  • Subscribe/Unsubscribe in OnEnable / OnDisable to avoid leaks.

  • Use OnBakeCompleted or OnOneShotBakeCompleted to safely trigger AI spawning.

  • Use OnBakeFailed for debug logs or fallback behavior.

  • Use Combined events only if relying on global combined-window mode (Grid Cells + Combine Tiles).

  • Runtime Spawner integration:

    • Pair with placement policies (Require, Prefer, Ignore).

    • For “Require”, defer spawning until OnBakeCompleted or OnOneShotBakeCompleted fires.

Last updated