API reference

SceneNavigation Class

Extends MonoBehaviour
Manages the creation and updating of a navigation mesh (NavMesh) for scene navigation.
This class handles dynamic NavMesh generation based on scene data, including rooms and anchors, and responds to changes in the scene.

Fields

AgentClimb : float
Signature
float AgentClimb
AgentHeight : float
Signature
float AgentHeight
AgentIndex : int
Signature
int AgentIndex
AgentMaxSlope : float
Signature
float AgentMaxSlope
AgentRadius : float
Signature
float AgentRadius
Agents : List< NavMeshAgent >
Signature
List<NavMeshAgent> Agents
BuildOnSceneLoaded : MRUK.RoomFilter
Signature
MRUK.RoomFilter BuildOnSceneLoaded
CollectGeometry : NavMeshCollectGeometry
Signature
NavMeshCollectGeometry CollectGeometry
CollectObjects : CollectObjects
Signature
CollectObjects CollectObjects
CustomAgent : bool
Signature
bool CustomAgent
Layers : LayerMask
Signature
LayerMask Layers
NavigableSurfaces : MRUKAnchor.SceneLabels
Signature
MRUKAnchor.SceneLabels NavigableSurfaces
OverrideTileSize : bool
Signature
bool OverrideTileSize
OverrideVoxelSize : bool
Signature
bool OverrideVoxelSize
SceneObstacles : MRUKAnchor.SceneLabels
Signature
MRUKAnchor.SceneLabels SceneObstacles
TileSize : int
Signature
int TileSize
UseSceneData : bool
Signature
bool UseSceneData
VoxelSize : float
Signature
float VoxelSize

Properties

Obstacles : Dictionary< MRUKAnchor, GameObject >
[Get]
Gets a dictionary mapping MRUKAnchor objects to their corresponding GameObjects that represent obstacles in the environment.
Signature
Dictionary<MRUKAnchor, GameObject> Obstacles
OnNavMeshInitialized : UnityEvent
[Get]
Event triggered when the navigation mesh has been initialized.
Signature
UnityEvent OnNavMeshInitialized
Surfaces : Dictionary< MRUKAnchor, GameObject >
[Get]
Gets a dictionary mapping MRUKAnchor objects to their corresponding GameObjects that represent surfaces in the environment.
Signature
Dictionary<MRUKAnchor, GameObject> Surfaces

Methods

BuildSceneNavMesh ()
Creates a navigation mesh for the entire scene.
Signature
void BuildSceneNavMesh()
Returns
void
BuildSceneNavMeshForRoom ( room )
Creates a navigation mesh for the scene.
This method creates a navigation mesh by collecting geometry from the scene, building the navigation mesh data, and adding it to the NavMesh. Currently, Unity does not allow the creation of custom NavMeshAgents at runtime. It also assigns the created navigation mesh to all NavMeshAgents in the scene.
Signature
void BuildSceneNavMeshForRoom(MRUKRoom room=null)
Parameters
room: MRUKRoom  Optional parameter for the MRUKRoom to create the NavMesh for. If not provided, obstacles will be created for all rooms.
Returns
void
ClearObstacle ( anchor )
Clears the obstacle associated with the given MRUKAnchor from the Obstacles dictionary.
Signature
void ClearObstacle(MRUKAnchor anchor)
Parameters
anchor: MRUKAnchor  The MRUKAnchor whose associated obstacle should be cleared.
Returns
void
ClearObstacles ( room )
Clears all obstacles from the Obstacles dictionary associated with the given MRUKRoom.
If no room is specified, all obstacles are cleared.
Signature
void ClearObstacles(MRUKRoom room=null)
Parameters
room: MRUKRoom  Optional parameter for the MRUKRoom to clear the obstacles for. If not provided, all obstacles will be cleared.
Returns
void
ClearSurface ( anchor )
Clears the surface associated with the given MRUKAnchor from the Obstacles dictionary.
Signature
void ClearSurface(MRUKAnchor anchor)
Parameters
anchor: MRUKAnchor  The MRUKAnchor whose associated obstacle should be cleared.
Returns
void
CreateNavigableSurfaces ( room )
Creating surfaces will not automatically build a new NavMesh. When changing surfaces at run time, always use BuildSceneNavMesh method
Signature
void CreateNavigableSurfaces(MRUKRoom room=null)
Parameters
room: MRUKRoom  Optional parameter for the MRUKRoom to create the navigable surfaces for. If not provided, navigable surfaces will be created for all rooms.
Returns
void
CreateNavMeshBuildSettings ( agentRadius , agentHeight , agentMaxSlope , agentClimb )
Creates a new NavMeshBuildSettings object with the specified agent properties.
Signature
NavMeshBuildSettings CreateNavMeshBuildSettings(float agentRadius, float agentHeight, float agentMaxSlope, float agentClimb)
Parameters
agentRadius: float  The minimum distance to the walls where the navigation mesh can exist.
agentHeight: float  How much vertical clearance space must exist.
agentMaxSlope: float  Maximum slope the agent can walk up.
agentClimb: float  The height of discontinuities in the level the agent can climb over (i.e. steps and stairs).
Returns
NavMeshBuildSettings  A new NavMeshBuildSettings object with the specified agent properties.
CreateNavMeshSurface ()
Creates a NavMeshSurface component and sets its properties.
Signature
void CreateNavMeshSurface()
Returns
void
CreateObstacle ( anchor , shouldCarve , carveOnlyStationary , carvingTimeToStationary , carvingMoveThreshold )
Creates a NavMeshObstacle for the given MRUKAnchor.
Signature
void CreateObstacle(MRUKAnchor anchor, bool shouldCarve=true, bool carveOnlyStationary=false, float carvingTimeToStationary=0.2f, float carvingMoveThreshold=0.2f)
Parameters
anchor: MRUKAnchor  The MRUKAnchor to create the obstacle for.
shouldCarve: bool  Optional parameter that determines whether the obstacle should carve the NavMesh. Default is true.
carveOnlyStationary: bool  Optional parameter that determines whether the obstacle should only carve the NavMesh when stationary. Default is true.
carvingTimeToStationary: float  Optional parameter that sets the time in seconds an obstacle must be stationary before it starts carving the NavMesh. Default is 0.2f.
carvingMoveThreshold: float  Optional parameter that sets the minimum world space distance the obstacle must move before it is considered moving. Default is 0.2f.
Returns
void
CreateObstacles ( room )
Creates obstacles for the given MRUKRoom or all rooms if no room is specified.
Signature
void CreateObstacles(MRUKRoom room=null)
Parameters
room: MRUKRoom  Optional parameter for the MRUKRoom to create the obstacles for. If not provided, obstacles will be created for all rooms.
Returns
void
CreateObstacles ( rooms )
Creates obstacles for the given MRUKRoom or all rooms if no room is specified.
Signature
void CreateObstacles(List< MRUKRoom > rooms)
Parameters
rooms: List< MRUKRoom >  The rooms for which obstacles will be created.
Returns
void
RemoveNavMeshData ()
Removes the NavMeshData from the NavMeshSurface component.
Signature
void RemoveNavMeshData()
Returns
void
ResizeNavMeshFromRoomBounds ( surface , room )
Resizes the NavMeshSurface to fit the room bounds.
Signature
Bounds ResizeNavMeshFromRoomBounds(ref NavMeshSurface surface, MRUKRoom room=null)
Parameters
surface: ref NavMeshSurface  The NavMeshSurface to resize.
room: MRUKRoom  The room bounds to use. Default is the current room.
Returns
Bounds  The bounds of the resized NavMeshSurface.
ResizeNavMeshFromRoomBounds ( surface , rooms )
Resizes the NavMeshSurface to fit the room bounds.
Signature
Bounds ResizeNavMeshFromRoomBounds(ref NavMeshSurface surface, List< MRUKRoom > rooms)
Parameters
surface: ref NavMeshSurface  The NavMeshSurface to resize.
rooms: List< MRUKRoom >  The rooms bounds to use.
Returns
Bounds  The bounds of the resized NavMeshSurface.
ToggleGlobalMeshNavigation ( useGlobalMesh , agentTypeID )
Toggles the use of global mesh for navigation.
Signature
void ToggleGlobalMeshNavigation(bool useGlobalMesh, int agentTypeID=-1)
Parameters
useGlobalMesh: bool  Whether to use the global mesh to build the NavMesh
agentTypeID: int  The agent type ID to use for creating the scene nav mesh, if not specified, a new agent will be created.
Returns
void

Static Methods

GetFirstLayerFromLayerMask ( layerMask )
Gets the first layer included in the given LayerMask.
Signature
static int GetFirstLayerFromLayerMask(LayerMask layerMask)
Parameters
layerMask: LayerMask  The LayerMask to get the first layer from.
Returns
int  Returns the first layer included in the LayerMask.
ValidateBuildSettings ( navMeshBuildSettings , navMeshBounds )
Validates the provided NavMeshBuildSettings against the provided NavMeshBounds.
Signature
static bool ValidateBuildSettings(NavMeshBuildSettings navMeshBuildSettings, Bounds navMeshBounds)
Parameters
navMeshBuildSettings: NavMeshBuildSettings  The NavMeshBuildSettings to validate.
navMeshBounds: Bounds  The Bounds to validate the NavMeshBuildSettings against.
Returns
bool  Returns true if the NavMeshBuildSettings are valid, false otherwise.