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

MRUK Class

Extends MonoBehaviour
This class contains convenience functions that allow you to query your scene.
It also contains functions to load a scene from prefabs or json to work within the Unity editor.

Member Enumerations

Enumeration PositioningMethod

When interacting specifically with tops of volumes, this can be used to specify where the return position should be aligned on the surface e.g.
some apps might want a position right in the center of the table (chess) for others, the edge may be more important (piano or pong)
DEFAULT
No description available
CENTER
No description available
EDGE
No description available

Enumeration SceneDataSource

Specify the source of the scene data.
Device
Load scene data from the device.
Prefab
Load scene data from prefabs.
DeviceWithPrefabFallback
First try to load data from the device and if none can be found fall back to loading from a prefab.
Json
Load Scene from a Json file.
DeviceWithJsonFallback
First try to load data from the device and if none can be found fall back to loading from a Json file.

Enumeration RoomFilter

Specifies the filtering options for selecting rooms within the scene data.
None
No description available
CurrentRoomOnly
No description available
AllRooms
No description available

Enumeration LoadDeviceResult

Return value from the call to LoadSceneFromDevice.
Success
Scene data loaded successfully.
NoScenePermission
User did not grant scene permissions.
NoRoomsFound
No rooms were found (e.g.
FailureDataIsInvalid
Invalid data.
FailureInsufficientResources
Resource limitation prevented this operation from executing.
FailureInsufficientView
Insufficient view.
FailurePermissionInsufficient
Insufficient permission.
FailureRateLimited
Operation canceled due to rate limiting.
FailureTooDark
Too dark.
FailureTooBright
Too bright.

Enumeration SurfaceType

Defines flags for different types of surfaces that can be identified or used within a scene.
FACING_UP
= 1 << 0
FACING_DOWN
= 1 << 1
VERTICAL
= 1 << 2

Properties

Gets a value indicating whether the component has been initialized.
Event that is triggered when the scene is loaded.
Event that is triggered when a room is created.
Event that is triggered when a room is updated.
Event that is triggered when a room is removed.
This property indicates if world lock is currently active.
This means that EnableWorldLock is enabled and the current room has successfully been localized. In some cases such as when the headset goes into standby, the user moves to another room and comes back out of standby the headset may fail to localize and this property will be false. The property may become true again once the device is able to localise the room again (e.g. if the user walks back into the original room). This property can be used to show a UI panel asking the user to return to their room.
OVRCameraRig _cameraRig[Get]
List of all the rooms in the scene.
Gets the singleton instance of the MRUK class.
The current configuration for the tracking service.
To request a particular configuration, set the desired values in MRUKSettings.TrackerConfiguration. This property represents the true state of the system. This may differ from what was requested with MRUKSettings.TrackerConfiguration if, for example, some types of trackables are not supported on the current device.

Fields

When world locking is enabled the position and rotation of the OVRCameraRig/TrackingSpace transform will be adjusted each frame to ensure the room anchors are where they should be relative to the camera position.
This is necessary to ensure the position of the virtual objects in the world do not get out of sync with the real world.
When the EnableWorldLock is enabled, MRUK will modify the TrackingSpace transform, overwriting any manual changes.
Use this field to change the position and rotation of the TrackingSpace transform when the world locking is enabled.
MRUKSettings SceneSettings[Get]

Member Functions

Register to receive a callback when the scene is loaded.
If the scene is already loaded at the time this is called, the callback will be invoked immediatly.
Parameters
callback
Register to receive a callback when a new room has been created from scene capture.
Parameters
callback
  • MRUKRoom The created room object.
Register to receive a callback when a room has been updated from scene capture.
Parameters
callback
  • MRUKRoom The updated room object.
Registers a callback function to be called before the room is removed.
Parameters
callback
The function to be called when the room is removed. It takes one parameter:
  • MRUKRoom The removed room object.
Get a list of all the rooms in the scene.
Returns
A list of MRUKRoom objects representing all the rooms in the scene.
Get a flat list of all Anchors in the scene.
Returns
A list of MRUKAnchor objects representing all the anchors in the current room.
Returns the current room the headset is in.
If the headset is not in any given room then it will return the room the headset was last in when this function was called. If the headset hasn't been in a valid room yet then return the first room in the list. If no rooms have been loaded yet then return null.
Returns
The current MRUKRoom based on the headset's position, or null if no rooms are available.
Destroys the rooms and all children.
Loads the scene based on scene data previously shared with the user via MRUKRoom.ShareRoomAsync.
This function should be used in co-located multi-player experiences by "guest" clients that require scene data previously shared by the "host".
Parameters
roomUuids
A collection of UUIDs of room anchors for which scene data will be loaded from the given group context.
groupUuid
UUID of the group from which to load the shared rooms.
alignmentData
Use this parameter to correctly align local and host coordinates when using co-location.
alignmentRoomUuid: the UUID of the room used for alignment.
floorWorldPoseOnHost: world-space pose of the FloorAnchor on the host device.
Using 'null' will disable the alignment, causing the mismatch between the host and the guest. Do this only if your app has custom coordinate alignment.
removeMissingRooms
When enabled, rooms that are already loaded but are not found in roomUuids will be removed. This is to support the case where a user deletes a room from their device and the change needs to be reflected in the app.
Returns
An enum indicating whether loading was successful or not.
Exceptions
ArgumentNullException
Thrown if roomUuids is null.
ArgumentException
Thrown if groupUuid equals Guid.Empty.
ArgumentException
Thrown if alignmentData.alignmentRoomUuid equals Guid.Empty.
Shares multiple MRUK rooms with a group.
Parameters
rooms
A collection of rooms to be shared.
groupUuid
UUID of the group to which the room should be shared.
Returns
A task that tracks the asynchronous operation.
Exceptions
ArgumentNullException
Thrown if rooms is null.
ArgumentException
Thrown if groupUuid equals Guid.Empty.
Loads the scene from the data stored on the device.
The user must have granted ScenePermissions or this will fail.In order to check if the user has granted permissions, call Permission.HasUserAuthorizedPermission(OVRPermissionsRequester.ScenePermission).In order to request permissions from the user, call Permission.RequestUserPermission(OVRPermissionsRequester.ScenePermission, callbacks).
Parameters
requestSceneCaptureIfNoDataFound
If true and no rooms are found when loading from device, the request space setup flow will be started.
removeMissingRooms
When enabled, rooms that are already loaded but are not found in newSceneData will be removed. This is to support the case where a user deletes a room from their device and the change needs to be reflected in the app.
Returns
An enum indicating whether loading was successful or not.
Simulates the creation of a scene in the Editor, using transforms and names from our prefab rooms.
Parameters
scenePrefab
The prefab GameObject representing the scene or a collection of rooms.
clearSceneFirst
If true, clears the current scene before loading the new one.
Serializes the scene data into a JSON string.
The scene data includes rooms, anchors, and their associated properties. The method allows for the specification of the coordinate system (Unity or Unreal) and whether to include the global mesh data.
Parameters
coordinateSystem
The coordinate system to use for the serialization (Unity or Unreal).
includeGlobalMesh
A boolean indicating whether to include the global mesh data in the serialization. Default is true.
rooms
A list of rooms to serialize, if this is null then all rooms will be serialized.
Returns
A JSON string representing the serialized scene data.
Loads the scene from a JSON string representing the scene data.
Parameters
jsonString
The JSON string containing the serialized scene data.
removeMissingRooms
When enabled, rooms that are already loaded but are not found in JSON the string will be removed.
Get all the trackables that have been detected so far.
Parameters
trackables
The list to populate with the trackables. The list is cleared before adding any elements.
Exceptions
ArgumentNullException
Thrown if trackables is null.

Static Member Functions

Checks whether any anchors can be loaded.
Returns
Returns a task-based bool, which is true if there are any scene anchors in the system, and false otherwise. If false is returned, then either the scene permission needs to be set, or the user has to run Scene Capture.
Did you find this page helpful?
Thumbs up icon
Thumbs down icon