[This is preliminary documentation and is subject to change.]

The NMGen ease-of-use extensions for Unity provide GUI-level access to almost all of the NMGen features. You can build navigation meshes with a single click. Or you can build, tweek, and rebuild selected zones of navigations meshes using advanced GUI features.

All NMGen assets and support code are 'editor only'. So they have zero impact on scene size and are not included in the Unity project build. (No data or code bloat.) The only impact on the scene will be if you need to create custom scene for things like off-mesh connections and area markers.

The Unity NMGen build process is pretty much the same as the standard build process describe by An Introduction to NMGen. The Unity extensions take care of gathering scene components and compiling them into input data, and provide ways to adjust the build via GUI editors rather than requiring you to code things.

The Main NMGen Build Assets

As noted above, the NMGen build process and all associated assets are implemented as project assets, not scene components. The only time you will need NMGen specific components in a scene is if you need to manually annotate something special that you want to include in the build. (E.g. Off-mesh connections.) The below diagram shows the main assets and how they are related from an input/output perspective.

Navmesh Build-Unity Main Assets

The central asset is the NavmeshBuild asset. It defines the build configuration and holds all intermediate build data created during the build.

The build uses a scene query asset to determine which scene components will be included in the build. Any ScritableObject that implements the ISceneQuery interface can be used. For example, if you want the build to gather scene components based on tags, then you'll use the TagSceneQuery asset.

Input processors do the heavy lifting such as triangulating MeshFilter and Terrain components, adding INMGenProcessor objects to the build, etc. Any ScriptableObject that implements the IInputBuildProcessor interface can be used.

The bake target is the asset that will get the result of the build. (The navigation mesh.) Any ScritableObject that implements the INavmeshData interface can be used. The normal target will be a CAIBakedNavmesh asset. Note that this is a navigation asset, not an NMGen asset, so it can be distributed as part of the project compile and be referenced by scene components.

The NavmeshBuild Asset

At the core of the Unity NMGen build process is the NavmeshBuild asset. It is created using one of the CritterAI->Create NMGenAsset->Navmesh Build menu items, usually the Standard option. Once added to the project you'll be presented with the following inspector.

Navmesh Build Inspector

The upper section of the inspector contains the primary build controls and build target assignment. Since it is possible to reassign the target you can use a single configuration to build any number of navigation meshes. Just reassign the target, open the target's input scene, and build.

The center section contains the NMGen configuration. It is defaults to values suitable for generic human-sized agents.

The lower section contains the input configuration. The scene query is optional. If none is provided then the search will be global. E.g. All MeshFilters in the scene. There has to be at least one input processor for the build to produce anything.

See Also