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

MRUKAnchor Class

Extends MonoBehaviour
Represents an anchor within MR Utility Kit, providing spatial and semantic information.

Member Enumerations

Enumeration SceneLabels

Flags enumeration for scene labels, indicating the type of object represented by an anchor and its classification.
FLOOR
= 1 << OVRSemanticLabels.Classification.Floor
CEILING
= 1 << OVRSemanticLabels.Classification.Ceiling
WALL_FACE
= 1 << OVRSemanticLabels.Classification.WallFace
TABLE
= 1 << OVRSemanticLabels.Classification.Table
COUCH
= 1 << OVRSemanticLabels.Classification.Couch
DOOR_FRAME
= 1 << OVRSemanticLabels.Classification.DoorFrame
WINDOW_FRAME
= 1 << OVRSemanticLabels.Classification.WindowFrame
OTHER
= 1 << OVRSemanticLabels.Classification.Other
STORAGE
= 1 << OVRSemanticLabels.Classification.Storage
BED
= 1 << OVRSemanticLabels.Classification.Bed
SCREEN
= 1 << OVRSemanticLabels.Classification.Screen
LAMP
= 1 << OVRSemanticLabels.Classification.Lamp
PLANT
= 1 << OVRSemanticLabels.Classification.Plant
WALL_ART
= 1 << OVRSemanticLabels.Classification.WallArt
GLOBAL_MESH
= 1 << OVRSemanticLabels.Classification.SceneMesh
INVISIBLE_WALL_FACE
= 1 << OVRSemanticLabels.Classification.InvisibleWallFace

Enumeration ComponentType

Flags enumeration for component type, scene anchors can either have plane or volume components associated with them or both.
None
= 0
Plane
= 1 << 0
Volume
= 1 << 1
All
= Plane | Volume

Properties

OVRSemanticLabels.DeprecationMessage
The scene label categorizing the anchor.
Optional rectangular bounds on a plane associated with the anchor.
Optional volumetric bounds associated with the anchor.
A list of local-space points defining the boundary of the plane associated with the anchor.
Reference to the scene anchor associated with this anchor.
You should not need to use this directly, only use this if you know what you are doing.
Reference to the parent room object.
This is set during construction.
References to child anchors, populated via MRUKRoom.CalculateHierarchyReferences.
A list of child anchors associated with this anchor.
Use PlaneRect.HasValue instead.
Use VolumeBounds.HasValue instead.
Use HasValidHandle instead.
An anchor will have a valid handle if it was loaded from device and there is a system level anchor backing it.
Anchors loaded from JSON or Prefabs do not have a valid handle. You should not need to use this directly, only use this if you know what you are doing. The behaviour may change in the future.
Mesh Mesh[Get]
The triangle mesh which covers the entire space, associated to the global mesh anchor.

Member Functions

Performs a raycast against the anchor's plane and volume to determine if and where a ray intersects.
This method avoids using colliders and Physics.Raycast for several reasons:
  • It requires tags/layers to filter out Scene API object hits from general raycasts, which can be intrusive to a developer's pipeline by altering their project settings.
  • It necessitates specific Plane and Volume prefabs that MRUK instantiates with colliders as children.
  • Using Physics.Raycast is considered overkill since the locations of all Scene API primitives are already known; thus, there's no need to raycast everywhere to find them.
Instead, this method uses Plane.Raycast and other custom methods to determine if the ray has hit the surface of the object.
Parameters
ray
The ray to test for intersections.
maxDist
The maximum distance the ray should check for intersections.
hitInfo
Output parameter that will contain the hit information if an intersection occurs.
componentTypes
The type of components to ray cast against.
Returns
True if the ray hits either the plane or the volume, false otherwise.
Determines if a given position is within the boundary of the plane associated with the anchor.
Parameters
position
The local space point to check.
Returns
True if the position is within the boundary, false otherwise.
Adds a reference to a child anchor.
Parameters
childObj
The child anchor to add.
Clears all references to child anchors.
Calculates the distance from a specified position to the closest surface of the anchor.
Parameters
position
The position from which to measure.
componentTypes
The component types to include.
Returns
The distance to the closest surface.
Finds the closest surface position from a given point and returns the distance to it.
Parameters
testPosition
The position to test.
closestPosition
The closest position on the surface.
componentTypes
The component types to include.
Returns
The distance to the closest surface position.
Finds the closest surface position from a given point, providing the position, normal at that position, and the distance.
If the point is inside a volume, it will return a negative distance representing the distance beneath the surface.
Parameters
testPosition
The position to test.
closestPosition
The closest position on the surface.
normal
The normal at the closest position.
componentTypes
The component types to include.
Returns
The distance to the closest surface position.
Gets the center position of the anchor.
If volume bounds are defined, it returns the center of the volume; otherwise, it returns the anchor's position.
Returns
The center position of the anchor.
A convenience function to get a transform-friendly Vector3 size of an anchor.
If you'd like the size of the quad or volume instead, use
See Also
MRUKAnchor.PlaneRect, MRUKAnchor.VolumeBounds
or
Returns
The size of the anchor
Retrieves the centers of the bounding box faces if a volume is defined, or the center of the plane if only a plane is defined.
Returns
An array of Vector3 representing the centers of the bounding box faces or the plane center.
Tests if a given world position is inside the volume of the anchor, considering an optional distance buffer and whether to test vertical bounds.
Parameters
worldPosition
The world position to test.
testVerticalBounds
Whether to include vertical bounds in the test.
distanceBuffer
An optional buffer distance to expand the volume for the test.
Returns
True if the position is inside the volume, false otherwise.
Loads a mesh representing the global mesh associated with the anchor, if available.
Returns
A Mesh object containing the triangles of the global mesh, or null if not available.
Checks if the current object has a specific label.
This method is obsolete. String-based labels are deprecated as of version 65. Please use the equivalent enum-based method.
Parameters
label
The label to check, provided as a string.
Returns
True if the object has the specified label, false otherwise.
Checks if the current object has any of the specified labels.
This method is obsolete. String-based labels are deprecated as of version 65. Please use the equivalent enum-based method.
Parameters
labels
A list of labels to check, provided as strings.
Returns
True if the object has any of the specified labels, false otherwise.
Checks if the anchor has any of the specified scene labels.
Parameters
labelFlags
The scene labels to check against the anchor's labels.
Returns
True if the anchor has any of the specified labels, false otherwise.
Retrieves the labels associated with this object as an enum.
This method is obsolete. Use the 'Label' property directly instead.
Returns
The labels as an enum of type SceneLabels.
OVRSemanticLabels.DeprecationMessage
Did you find this page helpful?
Thumbs up icon
Thumbs down icon