// Iterate through all the anchors in a room and print the label and the anchors' center
var room = MRUK.Instance.GetCurrentRoom();
foreach (var anchor in room.Anchors)
{
Debug.Log($"Anchor {anchor.Label} is centered at {anchor.GetAnchorCenter()}");
}Anchor
: OVRAnchor
[Get] |
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.
Signature
OVRAnchor Anchor |
ChildAnchors
: List< MRUKAnchor >
[Get] |
A list of child anchors associated with this anchor.
Signature
List<MRUKAnchor> ChildAnchors |
GlobalMesh
: Mesh
[Get] |
The triangle mesh which covers the entire space, associated to the global mesh anchor.
The global mesh is a low-fidelity, high-coverage artifact which describes the boundary between free and occupied space in a room. It is generated automatically during the space setup experience. Use cases:
Signature
Mesh GlobalMesh |
HasValidHandle
: bool
[Get] |
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.
Signature
bool HasValidHandle |
Label
: SceneLabels
[Get] |
The scene label categorizing the anchor.
This represents the semantic classification of the anchor, such as "WALL_FACE" or "TABLE".
Signature
SceneLabels Label |
ParentAnchor
: MRUKAnchor
[Get] |
References to child anchors, populated via MRUKRoom.CalculateHierarchyReferences.
Signature
MRUKAnchor ParentAnchor |
PlaneBoundary2D
: List< Vector2 >
[Get] |
A list of local-space points defining the boundary of the plane associated with the anchor.
This is useful for any spatial calculations.
Signature
List<Vector2> PlaneBoundary2D |
PlaneRect
: Rect?
[Get] |
Optional rectangular bounds on a plane associated with the anchor.
Examples of anchors with a plane are a wall or a floor.
Signature
Rect? PlaneRect |
Room
: MRUKRoom
[Get] |
Reference to the parent room object.
This is set during construction. Do not set this directly.
Signature
MRUKRoom Room |
VolumeBounds
: Bounds?
[Get] |
Optional volumetric bounds associated with the anchor.
Example of anchors with a volume are a table or a couch.
Signature
Bounds? VolumeBounds |
AddChildReference
(
childObj
)
|
Adds a reference to a child anchor.
Signature
void AddChildReference(MRUKAnchor childObj) Parameters Returns void |
ClearChildReferences
()
|
Clears all references to child anchors.
Signature
void ClearChildReferences() Returns void |
GetAnchorCenter
()
|
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.
Signature
Vector3 GetAnchorCenter() Returns Vector3Â
The center position of the anchor.
|
GetAnchorSize
()
|
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
Signature
Vector3 GetAnchorSize() Returns Vector3Â
The size of the anchor
|
GetBoundsFaceCenters
()
|
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.
Signature
Vector3[] GetBoundsFaceCenters() Returns Vector3[]Â
An array of Vector3 representing the centers of the bounding box faces or the plane center.
|
GetClosestSurfacePosition
(
testPosition
, closestPosition
, componentTypes
)
|
Finds the closest surface position from a given point and returns the distance to it.
Signature
float GetClosestSurfacePosition(Vector3 testPosition, out Vector3 closestPosition, ComponentType componentTypes=ComponentType.All) Parameters testPosition: Vector3Â
The position to test.
closestPosition: out Vector3Â
The closest position on the surface.
Returns floatÂ
The distance to the closest surface position.
|
GetClosestSurfacePosition
(
testPosition
, closestPosition
, normal
, componentTypes
)
|
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.
Signature
float GetClosestSurfacePosition(Vector3 testPosition, out Vector3 closestPosition, out Vector3 normal, ComponentType componentTypes=ComponentType.All) Parameters testPosition: Vector3Â
The position to test.
closestPosition: out Vector3Â
The closest position on the surface.
normal: out Vector3Â
The normal at the closest position.
Returns floatÂ
The distance to the closest surface position.
|
GetDistanceToSurface
(
position
, componentTypes
)
|
Calculates the distance from a specified position to the closest surface of the anchor.
Signature
float GetDistanceToSurface(Vector3 position, ComponentType componentTypes=ComponentType.All) Parameters position: Vector3Â
The position from which to measure.
Returns floatÂ
The distance to the closest surface.
|
GetLabelsAsEnum
()
|
Retrieves the labels associated with this object as an enum.
This method is obsolete. Use the 'Label' property directly instead.
Signature
SceneLabels GetLabelsAsEnum() |
HasAnyLabel
(
labels
)
|
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.
Signature
bool HasAnyLabel(List< string > labels) Parameters labels: List< string >Â
A list of labels to check, provided as strings.
Returns boolÂ
True if the object has any of the specified labels, false otherwise.
|
HasAnyLabel
(
labelFlags
)
|
Checks if the anchor has any of the specified scene labels.
Signature
bool HasAnyLabel(SceneLabels labelFlags) Parameters Returns boolÂ
True if the anchor has any of the specified labels, false otherwise.
|
HasLabel
(
label
)
|
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.
Signature
bool HasLabel(string label) Parameters label: stringÂ
The label to check, provided as a string.
Returns boolÂ
True if the object has the specified label, false otherwise.
|
IsPositionInBoundary
(
position
)
|
Determines if a given position is within the boundary of the plane associated with the anchor.
Signature
bool IsPositionInBoundary(Vector2 position) Parameters position: Vector2Â
The local space point to check.
Returns boolÂ
True if the position is within the boundary, false otherwise.
|
IsPositionInVolume
(
worldPosition
, testVerticalBounds
, distanceBuffer
)
|
Tests if a given world position is inside the volume of the anchor, considering an optional distance buffer and whether to test vertical bounds.
Signature
bool IsPositionInVolume(Vector3 worldPosition, bool testVerticalBounds, float distanceBuffer=0.0f) Parameters worldPosition: Vector3Â
The world position to test.
testVerticalBounds: boolÂ
Whether to include vertical bounds in the test.
distanceBuffer: floatÂ
An optional buffer distance to expand the volume for the test.
Returns boolÂ
True if the position is inside the volume, false otherwise.
|
LoadGlobalMeshTriangles
()
|
Loads a mesh representing the global mesh associated with the anchor, if available.
Signature
Mesh LoadGlobalMeshTriangles() Returns MeshÂ
A Mesh object containing the triangles of the global mesh, or null if not available.
|
Raycast
(
ray
, maxDist
, hitInfo
, componentTypes
)
|
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:
Signature
bool Raycast(Ray ray, float maxDist, out RaycastHit hitInfo, ComponentType componentTypes=ComponentType.All) Parameters ray: RayÂ
The ray to test for intersections.
maxDist: floatÂ
The maximum distance the ray should check for intersections.
hitInfo: out RaycastHitÂ
Output parameter that will contain the hit information if an intersection occurs.
Returns boolÂ
True if the ray hits either the plane or the volume, false otherwise.
|
| Member | Value |
|---|---|
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 |
| Member | Value |
|---|---|
None | 0 |
Plane | 1 << 0 |
Volume | 1 << 1 |
All | Plane | Volume |