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 Meta.XR.MRUtilityKit.MRUK.EnableWorldLock
SceneSettings : MRUKSettings
Signature
MRUKSettings Meta.XR.MRUtilityKit.MRUK.SceneSettings

Properties

Instance : MRUK
[Get]
Signature
MRUK Meta.XR.MRUtilityKit.MRUK.Instance
IsInitialized : bool
[Get]
Signature
bool Meta.XR.MRUtilityKit.MRUK.IsInitialized
RoomCreatedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is created.
Signature
UnityEvent<MRUKRoom> Meta.XR.MRUtilityKit.MRUK.RoomCreatedEvent
RoomRemovedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is removed.
Signature
UnityEvent<MRUKRoom> Meta.XR.MRUtilityKit.MRUK.RoomRemovedEvent
Rooms : List< MRUKRoom >
[Get]
List of all the rooms in the scene.
Signature
List<MRUKRoom> Meta.XR.MRUtilityKit.MRUK.Rooms
RoomUpdatedEvent : UnityEvent< MRUKRoom >
[Get]
Event that is triggered when a room is updated.
Signature
UnityEvent<MRUKRoom> Meta.XR.MRUtilityKit.MRUK.RoomUpdatedEvent
SceneLoadedEvent : UnityEvent
[Get]
Event that is triggered when the scene is loaded.
Signature
UnityEvent Meta.XR.MRUtilityKit.MRUK.SceneLoadedEvent

Methods

ClearScene ()
Destroys the rooms and all children.
Signature
void Meta.XR.MRUtilityKit.MRUK.ClearScene()
Returns
void
GetAnchors ()
Get a flat list of all Anchors in the scene.
Signature
List< MRUKAnchor > Meta.XR.MRUtilityKit.MRUK.GetAnchors()
Returns
List< MRUKAnchor >
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 Meta.XR.MRUtilityKit.MRUK.GetCurrentRoom()
Returns
MRUKRoom
GetRooms ()
Get a list of all the rooms in the scene.
Signature
List< MRUKRoom > Meta.XR.MRUtilityKit.MRUK.GetRooms()
Returns
List< MRUKRoom >
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 > Meta.XR.MRUtilityKit.MRUK.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 Meta.XR.MRUtilityKit.MRUK.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 )
This simulates the creation of a scene in the Editor, using transforms and names from our prefab rooms.
Signature
void Meta.XR.MRUtilityKit.MRUK.LoadSceneFromPrefab(GameObject scenePrefab, bool clearSceneFirst=true)
Parameters
scenePrefab: GameObject
clearSceneFirst: bool
Returns
void
RegisterRoomCreatedCallback ( callback )
Register to receive a callback when a new room has been created from scene capture.
Signature
void Meta.XR.MRUtilityKit.MRUK.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 Meta.XR.MRUtilityKit.MRUK.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 Meta.XR.MRUtilityKit.MRUK.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 Meta.XR.MRUtilityKit.MRUK.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 Meta.XR.MRUtilityKit.MRUK.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 > Meta.XR.MRUtilityKit.MRUK.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

Fields

DataSource : SceneDataSource
Signature
SceneDataSource Meta.XR.MRUtilityKit.MRUK.MRUKSettings.DataSource
LoadSceneOnStartup : bool
Signature
bool Meta.XR.MRUtilityKit.MRUK.MRUKSettings.LoadSceneOnStartup
RoomIndex : int
Signature
int Meta.XR.MRUtilityKit.MRUK.MRUKSettings.RoomIndex
RoomPrefabs : GameObject[]
Signature
GameObject [] Meta.XR.MRUtilityKit.MRUK.MRUKSettings.RoomPrefabs
SceneJsons : TextAsset[]
Signature
TextAsset [] Meta.XR.MRUtilityKit.MRUK.MRUKSettings.SceneJsons
SeatWidth : float
Signature
float Meta.XR.MRUtilityKit.MRUK.MRUKSettings.SeatWidth

Inner Struct

SceneTrackingSettings Struct

Inner Enums

PositioningMethod Enum

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

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

Enumeration Constants

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