API reference

MRUK Class

Extends MonoBehaviour
This class contains convenience functions that allow you to query your scene.

Fields

EnableWorldLock : bool
When world locking is enabled the position of the camera rig 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.
Signature
bool EnableWorldLock
SceneSettings : MRUKSettings
Signature
MRUKSettings SceneSettings

Properties

Instance : MRUK
[Get]
Gets the singleton instance of the MRUK class.
Signature
MRUK Instance
IsInitialized : bool
[Get]
Gets a value indicating whether the component has been initialized.
Signature
bool IsInitialized
RoomCreatedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is created.
Signature
UnityEvent<MRUKRoom> RoomCreatedEvent
RoomRemovedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is removed.
Signature
UnityEvent<MRUKRoom> RoomRemovedEvent
Rooms : List< MRUKRoom >
[Get]
List of all the rooms in the scene.
Signature
List<MRUKRoom> Rooms
RoomUpdatedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is updated.
Signature
UnityEvent<MRUKRoom> RoomUpdatedEvent
SceneLoadedEvent : UnityEvent
[Get]
Event that is triggered when the scene is loaded.
Signature
UnityEvent SceneLoadedEvent

Methods

ClearScene ()
Destroys the rooms and all children.
Signature
void ClearScene()
Returns
void
GetAnchors ()
Get a flat list of all Anchors in the scene.
Signature
List< MRUKAnchor > GetAnchors()
Returns
List< MRUKAnchor >  A list of MRUKAnchor objects representing all the anchors in the current room.
GetCurrentRoom ()
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.
Signature
MRUKRoom GetCurrentRoom()
Returns
MRUKRoom  The current MRUKRoom based on the headset's position, or null if no rooms are available.
GetRooms ()
Get a list of all the rooms in the scene.
Signature
List< MRUKRoom > GetRooms()
Returns
List< MRUKRoom >  A list of MRUKRoom objects representing all the rooms in the scene.
LoadSceneFromDevice ( requestSceneCaptureIfNoDataFound , removeMissingRooms )
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 use the following call: Permission.HasUserAuthorizedPermission(OVRPermissionsRequester.ScenePermission) In order to request permissions from the user, use the following call: Permission.RequestUserPermission(OVRPermissionsRequester.ScenePermission, callbacks);
Signature
async Task< LoadDeviceResult > LoadSceneFromDevice(bool requestSceneCaptureIfNoDataFound=true, bool removeMissingRooms=true)
Parameters
requestSceneCaptureIfNoDataFound: bool  If true and no rooms are found when loading from device, the request space setup flow will be started.
removeMissingRooms: bool  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
async Task< LoadDeviceResult >  An enum indicating whether loading was successful or not.
LoadSceneFromJsonString ( jsonString , removeMissingRooms )
Loads the scene from a JSON string representing the scene data.
Signature
void LoadSceneFromJsonString(string jsonString, bool removeMissingRooms=true)
Parameters
jsonString: string  The JSON string containing the serialized scene data.
removeMissingRooms: bool  When enabled, rooms that are already loaded but are not found in JSON the string will be removed.
Returns
void
LoadSceneFromPrefab ( scenePrefab , clearSceneFirst )
Simulates the creation of a scene in the Editor, using transforms and names from our prefab rooms.
Signature
void LoadSceneFromPrefab(GameObject scenePrefab, bool clearSceneFirst=true)
Parameters
scenePrefab: GameObject  The prefab GameObject representing the scene or a collection of rooms.
clearSceneFirst: bool  If true, clears the current scene before loading the new one.
Returns
void
RegisterRoomCreatedCallback ( callback )
Register to receive a callback when a new room has been created from scene capture.
Signature
void RegisterRoomCreatedCallback(UnityAction< MRUKRoom > callback)
Parameters
callback: UnityAction< MRUKRoom > 
  • MRUKRoom The created room object.
Returns
void
RegisterRoomRemovedCallback ( callback )
Registers a callback function to be called before the room is removed.
Signature
void RegisterRoomRemovedCallback(UnityAction< MRUKRoom > callback)
Parameters
callback: UnityAction< MRUKRoom >  The function to be called when the room is removed. It takes one parameter:
  • MRUKRoom The removed room object.
Returns
void
RegisterRoomUpdatedCallback ( callback )
Register to receive a callback when a room has been updated from scene capture.
Signature
void RegisterRoomUpdatedCallback(UnityAction< MRUKRoom > callback)
Parameters
callback: UnityAction< MRUKRoom > 
  • MRUKRoom The updated room object.
Returns
void
RegisterSceneLoadedCallback ( callback )
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.
Signature
void RegisterSceneLoadedCallback(UnityAction callback)
Parameters
callback: UnityAction
Returns
void
SaveSceneToJsonString ( coordinateSystem )
Serializes the current scene into a JSON string using the specified coordinate system for serialization.
Signature
string SaveSceneToJsonString(SerializationHelpers.CoordinateSystem coordinateSystem)
Parameters
coordinateSystem: SerializationHelpers.CoordinateSystem  The coordinate system to be used for serialization (Unity/Unreal).
Returns
string  A JSON string representing the serialized scene data.

Static Methods

HasSceneModel ()
Checks whether any anchors can be loaded.
Signature
static async Task< bool > HasSceneModel()
Returns
async Task< bool >  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.

Inner Class

MRUKSettings Class

Represents the settings for the MRUK instance, including data source configurations, startup behaviors, and other scene related settings.

Fields

DataSource : SceneDataSource
Signature
SceneDataSource DataSource
LoadSceneOnStartup : bool
Signature
bool LoadSceneOnStartup
RoomIndex : int
Signature
int RoomIndex
RoomPrefabs : GameObject[]
Signature
GameObject [] RoomPrefabs
SceneJsons : TextAsset[]
Signature
TextAsset [] SceneJsons
SeatWidth : float
Signature
float SeatWidth

Inner Struct

SceneTrackingSettings Struct

This struct is used to manage which rooms and anchors are not being tracked.

Inner Enums

PositioningMethod Enum

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)

Enumeration Constants

Member
DEFAULT
CENTER
EDGE

SceneDataSource Enum

Specify the source of the scene data.

Enumeration Constants

MemberDescription
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.

RoomFilter Enum

Specifies the filtering options for selecting rooms within the scene data.

Enumeration Constants

Member
None
CurrentRoomOnly
AllRooms

LoadDeviceResult Enum

Return value from the call to LoadSceneFromDevice.

Enumeration Constants

MemberValueDescription
Success
OVRAnchor.FetchResult.Success
Scene data loaded successfully.
NoScenePermission
1
User did not grant scene permissions.
NoRoomsFound
2
No rooms were found (e.g. User did not go through space setup)
FailureDataIsInvalid
OVRAnchor.FetchResult.FailureDataIsInvalid
Invalid data.
FailureInsufficientResources
OVRAnchor.FetchResult.FailureInsufficientResources
Resource limitation prevented this operation from executing. Recommend retrying, perhaps after a short delay and/or reducing memory consumption.
FailureInsufficientView
OVRAnchor.FetchResult.FailureInsufficientView
Insufficient view. The user needs to look around the environment more for anchor tracking to function.
FailurePermissionInsufficient
OVRAnchor.FetchResult.FailurePermissionInsufficient
Insufficient permission. Recommend confirming the status of the required permissions needed for using anchor APIs.
FailureRateLimited
OVRAnchor.FetchResult.FailureRateLimited
Operation canceled due to rate limiting. Recommend retrying after a short delay.
FailureTooDark
OVRAnchor.FetchResult.FailureTooDark
Too dark. The environment is too dark to load the anchor.
FailureTooBright
OVRAnchor.FetchResult.FailureTooBright
Too bright. The environment is too bright to load the anchor.

SurfaceType Enum

Defines flags for different types of surfaces that can be identified or used within a scene.

Enumeration Constants

MemberValue
FACING_UP
1 << 0
FACING_DOWN
1 << 1
VERTICAL
1 << 2