text
stringlengths 0
1.11k
|
|---|
A Meta Quest 2, Quest Pro, or Quest 3 with OS number of 60 or newer (check this in device settings).
|
PC: You can run the Unity Editor using Quest Link if you are on a PC. Keep in mind that the Passthrough image only appears in the headset. For Scene API, room data must exist before connecting device; disconnect Quest Link, run Room Setup on your Quest, then reconnect Quest Link.
|
Mac: If you are on a Mac, you must build an apk and deploy it to your device. You can use our MRUK.prefab to load an artificial room prefab in Editor.
|
Because MRUK is based on Scene API, first ensure you are familiar with the concepts.
|
Set up
|
Download and install the MR Utility Kit package:
|
Either add to your assets from the Unity Asset store, then select Packages: My Assets from the Unity Package Manager, click on Meta MR Utility Kit and install.
|
or Download from Meta as a tarball, extract it to your computer, choose Add package from disk from the Unity Package Manager, and select the package.json you unzipped.
|
Ensure Passthrough is working in your project by following these instructions.
|
Ensure Scene is working by following these instructions.
|
Capture your room in our Space Setup tool, found in the Oculus settings menu.
|
Creating a new scene
|
In addition to the OVRCameraRig, ensure your scene contains the MRUK prefab. The MRUK class is a singleton that should only exist once within the scene. When using Scene API data, you must wait until the room has loaded, or your app likely won’t function properly. This loading event is conveyed by MRUK’s SceneLoadedEvent. For simplicity, this is exposed in the Inspector for you to drop your public functions.
|
Scene Loaded Event
|
To properly initialize your own game objects:
|
In your code, add public initialization functions:
|
Click the “+” to add a new field to this Scene Loaded Event list.
|
Drag the game object with your initialization code to the empty field, selecting your component and pointing to your function.
|
Keep in mind that list order matters; if you have initialization dependencies between scripts, make sure that the functions you’d like to execute first are at the top of the event list.
|
NOTE: You do NOT need OVRSceneManager in your scene, MRUK serves as a replacement for it. In v60 there is an issue that can cause your camera to flicker back and forth when both are used together.
|
Press play
|
A benefit of MRUK is that it can fallback to imitation anchor data during play in Editor mode, for quicker iteration than building an apk. For example, when pressing Play on the MRUKBase scene, you can see a list of anchors and a visualization of the room:
|
PlayModeRoom
|
(The room choice is random by default, and specified on the MRUK prefab)
|
For other development options in Editor, you can also use Oculus Link for your real room, or the Meta XR Simulator with simulated rooms.
|
Features
|
There are a couple of ways to use MR Utility Kit: engineering through code, or adjusting parameters of the prefab Tools within Unity Inspector.
|
Code
|
When engineering, you will primarily interact with the MRUK, MRUKRoom and MRUKAnchor classes. MRUK is a singleton class, there should only be one instance of this in your scene. There is one MRUKRoom instance per room, and all of its children have a MRUKAnchor component. This structure is analagous to OVRSceneRoom and OVRSceneAnchor when using OVRSceneManager.
|
MRUK
|
LoadSceneFromDevice(): Load the scene data from the quest device
|
LoadSceneFromPrefab(): Load the scene from one of the provided prefabs or your own
|
ClearScene(): Clear the scene data
|
GetRooms(): Get the list of rooms currently loaded
|
GetCurrentRoom(): Get the room the user is currently in
|
MRUKRoom
|
GetRoomAnchors(): Access to all MRUKAnchors in the room (not including the anchor on the room itself)
|
GetFloorAnchor(): Access to the floor MRUKAnchor
|
GetCeilingAnchor(): Access to the ceiling MRUKAnchor
|
GetGlobalMeshAnchor(): Access to the global mesh MRUKAnchor
|
GetWallAnchors(): Access to all the wall MRUKAnchors in the room
|
GetRoomOutline(): Get the bottom corner points of the room, in clockwise winding order (when viewed top-down)
|
GetKeyWall(): Get the longest wall in the room that has NO other room corners behind it (within a tolerance)
|
Raycast()/RaycastAll(): Collider-free raycast against only the anchors in the room; note that hit order is not guaranteed
|
GetBestPoseFromRaycast(): Get a suggested pose from a raycast. Useful for placing AR content with a controller.
|
IsPositionInRoom(): Check if a position is within the room outline
|
GetRoomBounds(): World-aligned bounding box for macro functionality
|
GetFacingDirection(): For volumes, get a “likely” Y-forward vector based on the closest wall face direction
|
IsPositionInSceneVolume(): Check if a position is within any volumes in the room
|
TryGetClosestSeatPose(): From a Ray, returns the closest seat Pose on any Couch objects
|
GetSeatPoses(): Returns all seat Poses in the room (0 if the room has no Couch objects)
|
TryGetAnchorParent(): Because there’s a flat scene hierarchy (room & anchors), this tries to find a logical one; for example if you wanted to know which wall a door is attached to, or if a volume is stacked on another.
|
TryGetAnchorChildren(): Similar to above, but for the opposite relationship
|
DoesRoomHave(): One-line access to see if any object in the room has a semantic label
|
TryGetClosestSurfacePosition(): Used mainly for the RoomGuardian prefab, it returns the closet point on any Scene surface
|
FindLargestSurface(): Returns the anchor with the largest available surface area
|
GenerateRandomPositionInRoom(): Generate a random position in a room, while avoiding volume scene objects and points that are too close to surfaces
|
GenerateRandomPositionOnSurface(): Generate a position on any valid surface in the room
|
MRUKAnchor
|
Raycast(): Collider-free raycast against this anchor
|
IsPositionInBoundary(): Determine if a position is within a plane’s 2D boundary (false if object has no plane)
|
GetDistanceToSurface(): Get the shortest distance from a point to the surface of this anchor
|
GetClosestSurfacePosition(): Get the closest position on the anchor’s surface to a given point
|
GetAnchorCenter(): Using transform.position on Scene API volumes isn’t correct, since the position is on the top of the volume. This returns the centroid
|
GetAnchorSize(): Get a Vector3 scale of an anchor, preferring the volume. Note that some anchors have both 2D and 3D bounds, so if you want specific scale:
|
PlaneRect.Value.size: (Returns a Vector2: first check if HasPlane is true)
|
VolumeBounds.Value.size: (Returns a Vector3: first check if HasVolume is true)
|
AnchorLabels: Query this to understand which semantic labels this anchor has
|
GetBoundsFaceCenters(): Get the center points of each surface (1 for planes, 6 for volumes)
|
IsPositionInVolume(): Test if a position is inside this volume
|
HasLabel(): Check if an anchor has a specific Semantic label
|
GetLabelsAsEnum(): Get all Semantic labels of this object
|
World locking
|
World locking is a new feature that makes it easier for developers to keep the virtual world in sync with the real world. Virtual content can be placed arbitrarily in the scene without needing to explicitly attach it to anchors, MRUK takes care of keeping the camera in sync with the real world using scene anchors under the hood. This is achieved by making small imperceptible adjustments to the camera rig’s tracking space transform optimizing it such that nearby scene anchors appear in the right place.
|
Previously, the recommended method to keep the real and virtual world in sync was to ensure that every piece of virtual content is attached to an anchor. This meant that nothing could be considered static and would need to cope with being moved by small amounts every frame. This can lead to a number of issues with networking, physics, rendering, etc. When world locking is enabled, virtual content can remain static. The space close to the player will remain in sync however the trade off is that space further away may diverge from the physical world by a small amount.
|
World locking is enabled by default but can be disabled by setting EnableWorldLock to false on the MRUK instance.
|
Tools
|
These prefabs in the Core/Tools folder are designed to be dropped in your scene and optionally modified in the Inspector interface. Note that some of these prefabs have an MRUKStart component on them; this is for drag-and-drop ease of use. However, if your code has initialization dependencies, you will need to manually organize your initialization functions into one ordered list (preferably on the MRUK prefab). An example of this is if you would like to access the EffectMesh’s mesh from your own game code, you must ensure the EffectMesh.CreateMesh() function executes first by being above your code’s function in a single Scene Loaded Event list. In steps, this would be:
|
Drag the MRUK and EffectMesh prefabs into the scene. Remove the MRUKStart component on the EffectMesh prefab.
|
On the MRUK prefab, add the EffectMesh.CreateMesh() function to the Scene Loaded Event list.
|
Add your own initialization code to the list below that.
|
MRUK
|
Required to use MR Utility Kit.
|
MRUK
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.