/// Overrides navmesh generation settings for a single mesh or collider.
///
/// Sometimes you want to tweak the <see cref="RecastGraph"/> on a per-object basis. For example you might want to make some objects completely unwalkable, or you might want to special case some objects to remove them from the navmesh altogether.
///
/// You can do this using the <see cref="RecastNavmeshModifier"/> component. Attach it to any object you want to modify and configure the settings as you wish.
///
/// Using the <see cref="RecastNavmeshModifier"/> component you can:
///
/// - Exclude an object from the graph's scan completely.
/// - Ensure an object is included in the scan, even if it would normally be excluded.
/// - Make the surfaces of an object unwalkable.
/// - Make the surfaces of an object walkable (this is just the default behavior).
/// - Create seams in the navmesh between adjacent objects.
/// - Mark the surfaces of an object with a specific tag (see tags) (view in online documentation for working links).
///
/// Adding this component to an object will make sure it is included in any recast graphs.
/// It will be included even if the Rasterize Meshes toggle is set to false.
///
/// If you are using the Rasterize Meshes option on the recast graph, and you are updating the graph during runtime,
/// then disabling it and attaching RecastNavmeshModifiers (with <see cref="dynamic"/> set to false) to the objects you want to rasterize can be good for performance.
/// This is because it's not possible to find meshes in the scene efficiently in Unity, so every time even a small part of the graph is updated, it has to search all meshes in the scene for ones to rasterize.
/// This can be slow if you have a lot of meshes in the scene. RecastNavmeshModifiers are stored in a tree for extremely fast lookup (O(log n + k)
/// compared to O(n) where n is the number of meshes in your scene and k is the number of meshes which should be rasterized, if you know Big-O notation.
/// But as always, profile before you optimize.
///
/// Note: If <see cref="dynamic"/> is false, then the object is not allowed to move. If it does, the internal lookup tree will be incorrect and the graph may not be updated correctly.
///
/// See: You can also do similar changes on a per-layer basis using <see cref="RecastGraph.perLayerModifications"/>.
/// Includes or excludes the object as normal based on the recast graph's layer mask and tag mask.
///
/// See: <see cref="RecastGraph.mask"/>
/// </summary>
Auto,
/// <summary>This object will be completely ignored by the graph</summary>
AlwaysExclude,
/// <summary>This object will always be included when scanning a recast graph, even if it would normally be filtered out</summary>
AlwaysInclude,
}
/// <summary>Source of geometry when voxelizing this object</summary>
publicenumGeometrySource{
/// <summary>Uses the MeshFilter component on this GameObject if available, otherwise uses the collider</summary>
Auto,
/// <summary>Always uses the MeshFilter component on this GameObject</summary>
MeshFilter,
/// <summary>Always uses the Collider on this GameObject</summary>
Collider,
}
publicenumMode{
/// <summary>All surfaces on this mesh will be made unwalkable</summary>
UnwalkableSurface=1,
/// <summary>All surfaces on this mesh will be walkable</summary>
WalkableSurface,
/// <summary>All surfaces on this mesh will be walkable and a seam will be created between the surfaces on this mesh and the surfaces on other meshes (with a different surface id)</summary>
WalkableSurfaceWithSeam,
/// <summary>All surfaces on this mesh will be walkable and the nodes will be given the specified tag. A seam will be created between the surfaces on this mesh and the surfaces on other meshes (with a different tag or surface id)</summary>
WalkableSurfaceWithTag,
}
/// <summary>
/// Voxel area for mesh.
/// This area (not to be confused with pathfinding areas, this is only used when rasterizing meshes for the recast graph) field
/// can be used to explicitly insert edges in the navmesh geometry or to make some parts of the mesh unwalkable.
///
/// When rasterizing the world and two objects with different surface id values are adjacent to each other, a split in the navmesh geometry
/// will be added between them, characters will still be able to walk between them, but this can be useful when working with navmesh updates.
///
/// Navmesh updates which recalculate a whole tile (updatePhysics=True) are very slow So if there are special places
/// which you know are going to be updated quite often, for example at a door opening (opened/closed door) you
/// can use surface IDs to create splits on the navmesh for easier updating using normal graph updates (updatePhysics=False).
/// When <see cref="mode"/> is set to Mode.WalkableSurfaceWithTag then this value will be interpreted as a pathfinding tag. See tags (view in online documentation for working links).
///
/// Note: This only has an effect if <see cref="mode"/> is set to Mode.WalkableSurfaceWithSeam or Mode.WalkableSurfaceWithTag.
// When using static baching, the bounds of the object may shrink.
// In particular, if the object has been rotated, the renderer's bounds will originally use an approximation of the AABB (presumably just the original AABB, but rotated and then axis aligned again),
// but after static batching, it actually looks at the new mesh (with the rotation baked in), and can generate a more precise AABB (which may be smaller).
// Therefore we say that it's ok as long as the original bounds contain the new bounds.
// This is fine, because the tree only needs a bounding box which contains the object. If it's too big, it will just be a bit more conservative.
// Also expand the original bounding box by a tiny amount to work around floating point errors.
Debug.LogError("The RecastNavmeshModifier has been moved or resized since it was enabled. You should set dynamic to true for moving objects, or disable the component while moving it. The bounds changed from "+originalBounds+" to "+newBounds,this);