API reference
API reference
Select your platform
No SDKs available
No versions available

MRUKRoom Class

Extends MonoBehaviour
Represents a room within MR Utility Kit, containing various anchors and providing a set of utility functions.

Properties

The primary anchor associated with the room.
A room is considered local if it was loaded from device.
If it was loaded from some other source, e.g. JSON or Prefab then it is not local.
Contains all the scene anchors in the room.
Contains all the wall anchors in the room.
The floor anchor in the room.
The ceiling anchor in the room.
The global mesh anchor in the room.
Contains a list of suggested seat placements within the room, specifically on couch objects.
Each seat pose is defined relative to the couch anchor's space.
Gets fired when a new anchor of this room has been created.
Gets fired after a component of the corresponding anchor has changed.
Gets fired when the anchor has been deleted.

Member Functions

Registers a callback function to be called when an anchor is created.
Parameters
callback
The function to be called when an anchor is created. It takes one parameter:
  • MRUKAnchor The created anchor object.
Registers a callback function to be called before an anchor is updated.
Parameters
callback
The function to be called when an anchor is updated. It takes one parameter:
  • MRUKAnchor The updated anchor object.
Registers a callback function to be called when an anchor is removed.
Parameters
callback
The function to be called when an anchor is removed. It takes one parameter:
  • MRUKAnchor The removed anchor object.
UnRegisters a callback function to be called when an anchor is created.
Parameters
callback
The function to be called when an anchor is created. It takes one parameter:
  • MRUKAnchor The created anchor object.
UnRegisters a callback function to be called before an anchor is updated.
Parameters
callback
The function to be called when an anchor is updated. It takes one parameter:
  • MRUKAnchor The updated anchor object.
UnRegisters a callback function to be called when an anchor is removed.
Parameters
callback
The function to be called when an anchor is removed. It takes one parameter:
  • MRUKAnchor The removed anchor object.
Shares this room with the specified group.
Parameters
groupUuid
UUID of the group to which the room should be shared.
Returns
A task that tracks the asynchronous operation.
Exceptions
InvalidOperationException
Thrown if Anchor is OVRAnchor.Null
ArgumentException
Thrown if groupUuid is empty.
Returns all the Scene objects (anchors) in the room.
Useful if you want to do your own calculations within the Mixed Reality Utility Kit framework.
Returns
A list of MRUKAnchor objects representing the anchors in the room.
Removes an anchor from the internal list and destroys the gameobject and it's children.
Parameters
anchor
The Anchor to remove and destroy
Retrieves the floor anchor of this room.
Returns
The floor anchor.
Retrieves the ceiling anchor of this room.
Returns
The ceiling anchor.
Retrieves the global mesh anchor of this room.
Returns
The global mesh anchor.
stead")]
Retrieves the list of wall anchors of this room.
Returns
A list of wall anchors.
Retrieves a clockwise (when viewed top-down) list of wall corner points at floor level.
This method is useful for obtaining the geometric outline of a room based on its walls.
Returns
A list of Vector3 points representing the corners of the room's walls at floor level, arranged in a clockwise order.
Identifies the key wall in the room.
A key wall is the longest wall with no other room points behind it, allowing for a more controlled artistic environment, akin to a stage. This method is useful for scenarios where a clear, unobstructed view of one wall is necessary. Can be used to craft a "stage-like" environment.
Parameters
wallScale
Outputs the scale of the key wall, if found.
tolerance
A tolerance value to account for precision issues in determining if points are behind the wall.
Returns
The anchor representing the key wall, or null if no suitable wall is found.
Casts a ray against ONLY Scene API objects, returning all results.
This method is used as a replacement for Physics.RaycastAll, specifically tailored to interact with Scene API objects.
Parameters
ray
The ray to cast.
maxDist
The maximum distance the ray should check for collisions.
labelFilter
The filter to apply to scene anchors to determine which ones should be considered.
raycastHits
A list to store the RaycastHit results.
anchorList
A list to store the MRUKAnchor objects hit by the ray.
Returns
True if one or more objects were hit, false otherwise.
Casts a ray against ONLY Scene API objects, returning the closest result.
This method is used as a replacement for Physics.Raycast, specifically tailored to interact with Scene API objects.
Parameters
ray
The ray to cast.
maxDist
The maximum distance the ray should check for collisions.
labelFilter
The filter to apply to scene anchors to determine which ones should be considered.
hit
The closest RaycastHit result, if any.
outAnchor
The MRUKAnchor associated with the closest hit, if any.
Returns
True if an object was hit, false otherwise.
Casts a ray against ONLY Scene API objects, returning the closest result.
This method is used as a replacement for Physics.Raycast, without specifying a label filter.
Parameters
ray
The ray to cast.
maxDist
The maximum distance the ray should check for collisions.
hit
The closest RaycastHit result, if any.
anchor
The MRUKAnchor associated with the closest hit, if any.
Returns
True if an object was hit, false otherwise.
Casts a ray against ONLY Scene API objects, returning the closest result.
This method is used as a replacement for Physics.Raycast, allowing for a specified label filter but not returning the anchor.
Parameters
ray
The ray to cast.
maxDist
The maximum distance the ray should check for collisions.
labelFilter
The filter to apply to scene anchors to determine which ones should be considered.
hit
The closest RaycastHit result, if any.
Returns
True if an object was hit, false otherwise.
Casts a ray against ONLY Scene API objects, returning the closest result.
This method is used as a replacement for Physics.Raycast, without specifying a label filter or returning the anchor.
Parameters
ray
The ray to cast.
maxDist
The maximum distance the ray should check for collisions.
hit
The closest RaycastHit result, if any.
Returns
True if an object was hit, false otherwise.
Calculates the best pose based on a raycast, considering specific label filters and positioning methods.
This method is useful for determining the optimal position and orientation for placing objects in a scene based on surface interactions. i.e. how best to "place an app/widget" on a surface.
  • When hitting vertical surfaces; Y is world-up, Z is surface normal.
  • When hitting horizontal surfaces; Y is world-up, Z is best-guess at player-facing.
  • "best guess" = when on ceiling/floor, Z faces player; when on surface (desk/couch), Z faces closest edge to player
Parameters
ray
The ray to cast into the scene.
maxDist
The maximum distance the ray should check for collisions.
labelFilter
The filter to apply to scene anchors to determine which ones should be considered.
sceneAnchor
The scene anchor that the raycast hit, if any.
surfaceNormal
The normal of the surface at the hit point.
positioningMethod
The method to use for positioning the pose. Defaults to MRUK.PositioningMethod.DEFAULT.
Returns
The best pose calculated from the raycast, or a default pose if no suitable surface is found.
Calculates the best pose based on a raycast, considering specific label filters and positioning methods.
This version of the method does not return the surface normal explicitly.
Parameters
ray
The ray to cast into the scene.
maxDist
The maximum distance the ray should check for collisions.
labelFilter
The filter to apply to scene anchors to determine which ones should be considered.
sceneAnchor
The scene anchor that the raycast hit, if any.
positioningMethod
The method to use for positioning the pose. Defaults to MRUK.PositioningMethod.DEFAULT.
Returns
The best pose calculated from the raycast, or a default pose if no suitable surface is found.
Tests if a given position is inside the floor outline of the room's walls.
This method can optionally test the vertical bounds to ensure the position is not outside the room's floor or ceiling, preventing the room from being treated as an "infinite column."
Parameters
queryPosition
The world position to test.
testVerticalBounds
If true, the method also checks if the position is within the vertical bounds of the room (floor and ceiling). Defaults to true.
Returns
True if the position is within the room's boundaries, false otherwise.
Get a world-oriented bounding box of the room.
Returns
The bounding box that encapsulates the entire room.
Test if a position is inside of a Scene volume, and optionally return the object.

To also check if a position is inside the room walls, use IsPositionInRoom().
Use distanceBuffer as a cheap way to check volume intersection.
Parameters
worldPosition
The world position to test.
sceneObject
The scene object that the position is inside of, if any.
testVerticalBounds
Whether to test vertical bounds of the volume.
distanceBuffer
A buffer distance for volume intersection tests.
Returns
True if the position is inside a scene volume, false otherwise.
Get a "likely" direction this anchor is facing.
For planes, this is always the normal (Z-forward). For volumes, we use contextual clues; primarily, the closest wall is the "back" of the volume, and the facing direction is its axis most aligned with this wall normal.
Parameters
anchor
The anchor to evaluate.
Returns
The facing direction of the anchor.
Test if a position is inside of a Scene volume (couch, desk, etc.).

To also check if a position is inside the room walls, use IsPositionInRoom().
Use distanceBuffer as a cheap way to check volume intersection.
Parameters
worldPosition
The world position to test.
distanceBuffer
A buffer distance for volume intersection tests, defaults to 0.0f.
Returns
True if the position is inside a scene volume, false otherwise.
Test if a position is inside of a Scene volume (couch, desk, etc.).

To also check if a position is inside the room walls, use IsPositionInRoom().
Use distanceBuffer as a cheap way to check volume intersection.///
Parameters
worldPosition
The world position to test.
testVerticalBounds
Whether to test vertical bounds of the volume.
distanceBuffer
A buffer distance for volume intersection tests, defaults to 0.0f.
Returns
True if the position is inside a scene volume, false otherwise.
Returns the best-suggested seat, for scenarios like remote caller placement.
Parameters
ray
The ray to use for finding the closest seat.
seatPose
The pose of the closest seat.
couch
The anchor associated with the closest seat.
Returns
True if a seat is found, false otherwise.
Returns all seats in the room (a human-spaced position on a couch).
Returns
An array of poses representing all seats in the room.
Attempts to return the parent of an anchor, if it exists.
This hierarchical relationship is by reference, not literally in the scene.
Parameters
queryAnchor
The anchor for which to find the parent.
parentAnchor
The parent anchor, if one exists.
Returns
True if the parent anchor exists, otherwise false.
Attempts to return the logical children of an anchor, if there are any.
This hierarchical relationship is by reference, not literally in the scene.
Parameters
queryAnchor
The anchor for which to find the children.
childAnchors
An array of child anchors, if any exist.
Returns
True if there are one or more child anchors, otherwise false.
Checks if the room contains all specified labels.
This method is obsolete. Use HasAllLabels instead. OVRSemanticLabels.DeprecationMessage
Parameters
labels
Array of label names to check.
Returns
True if the room contains all specified labels, otherwise false.
Determines whether a room contains all the provided Scene API labels.
Parameters
labelFlags
The labels to check, represented as a combination of MRUKAnchor.SceneLabels.
Returns
True if the room contains all specified labels, otherwise false.
Attempts to find the closest surface position to a given world position within the room, considering only anchors that pass the specified label filter.
Parameters
worldPosition
The world position from which to find the closest surface.
surfacePosition
The closest surface position to the specified world position, if found.
closestAnchor
The anchor associated with the closest surface position, if found.
labelFilter
A filter to apply to the anchors when searching for the closest surface. Defaults to an empty filter, which includes all labels.
Returns
The distance to the closest surface position. Returns Mathf.Infinity if no valid surface is found.
Attempts to find the closest surface position to a given world position within the room, considering only anchors that pass the specified label filter.
Parameters
worldPosition
The world position from which to find the closest surface.
surfacePosition
The closest surface position to the specified world position, if found.
closestAnchor
The anchor associated with the closest surface position, if found.
normal
The normal of the closest surface position, if found.
labelFilter
A filter to apply to the anchors when searching for the closest surface. Defaults to an empty filter, which includes all labels.
Returns
The distance to the closest surface position. Returns Mathf.Infinity if no valid surface is found.
Finds the largest surface within the room based on the specified anchor label.
This method is obsolete and should not be used in new code.
Parameters
anchorLabel
The label of the anchor as a string.
Returns
The MRUKAnchor associated with the largest surface that matches the specified label.
Finds the anchor with the largest available surface area that matches the specified label flags.
This method is more flexible than checking for specific conditions like table space and can be adapted for various usage scenarios.
Parameters
labelFlags
The labels to consider when searching for the largest surface. These are represented as a combination of MRUKAnchor.SceneLabels.
Returns
The MRUKAnchor with the largest surface area that matches the specified labels, or null if no suitable anchor is found.
Generate a random position in a room, while avoiding volume scene objects and points that are too close to surfaces.
This function uses random sampling and a maximum number of iterations.
Parameters
minDistanceToSurface
Reject points whose proximity to a surface is less than the parameter.
avoidVolumes
Do not allow points to be within volume scene objects.
Returns
A position that adhers to the constraints, null otherwise.
Generate a position on any valid surface in the room, limited by the type of surface and the classification of the object.
Parameters
surfaceTypes
The type of surface by which to limit the generation.
minDistanceToEdge
Limit the generated point to not being close to a surface's edges and corners.
labelFilter
The labels to include
position
The generated position. Vector3.zero is returned if no position was generated.
normal
The generated surface normal. Vector3.zero is returned if nothing was generated.
Returns
True if a position was found, false otherwise.

Static Member Functions

Sorts a list of wall anchors based on the width of their associated planes.
This method is useful for organizing walls in ascending order of their widths, which can be helpful for operations that require processing walls from narrowest to widest or for selecting specific walls based on their size.
Parameters
walls
The list of wall anchors to sort.
Returns
A new list of wall anchors sorted by the width of their planes.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon