Develop

MRUKBase sample overview

Updated: May 6, 2026

Overview

This sample demonstrates the core functionality of MR Utility Kit by visualizing your physical room as semi-transparent mesh overlays on walls, floors, ceilings, and furniture. It uses prefab-based configuration with only one custom script, making it ideal for developers new to MRUK who want to understand the foundational scene data pipeline and world lock monitoring.

What you will learn

  • Configure MRUK and EffectMesh prefabs for automatic scene visualization
  • Subscribe to scene load events and query room data
  • Monitor world lock status and respond to tracking changes
  • Use EffectMesh to generate meshes for physical surfaces
  • How passthrough integration displays the physical environment alongside virtual content

Requirements

Device: Meta Quest 2, Quest 3, or Quest 3S
Development environment: Unity 2022.3 or later with Meta XR SDK installed
For complete platform setup instructions, see Unity development setup.

Get started

Clone or download the Unity-MRUtilityKitSample repository from GitHub. Open the project in Unity and navigate to Assets/MRUKSamples/Basic/MRUKBase.unity. Build and deploy the scene to your Quest device using the standard Unity build workflow. For detailed build instructions and troubleshooting, see the repository’s README.

Explore the sample

The Basic scene uses four key components to demonstrate MRUK’s core visualization pipeline.
ComponentWhat it demonstratesKey concepts
MRUKBase.unity
Complete scene setup with MRUK and EffectMesh prefabs
Prefab-based configuration, Inspector-driven workflow
OVRCameraRig
Passthrough integration with Stage tracking
Passthrough rendering, tracking origin modes
MRUK prefab
Scene data loading with device-first fallback
SceneDataSource modes, scene loading events
EffectMesh prefab
Automatic mesh generation for room surfaces
Label filtering, spawn timing, mesh visualization
The sample includes one custom script, WorldLockTint.cs, which monitors world lock status and provides visual feedback. See Key concepts for details.

Runtime behavior

When you run the sample on your Quest device, your physical room appears through passthrough with semi-transparent mesh overlays on all detected surfaces including walls, floor, ceiling, tables, couches, and other furniture. If the device loses tracking or localization, all mesh overlays turn red as a visual warning. When tracking recovers, the overlays return to their default color. Hand tracking provides interactive presence throughout the experience.

Key concepts

Prefab-based scene setup

The sample requires no code for basic visualization. Drop the MRUK prefab into your scene to enable scene data loading, then add the EffectMesh prefab to generate mesh overlays. Configure the DataSource field on MRUK to DeviceWithPrefabFallback to load room data from the device first. If device data is unavailable, the system falls back to bundled prefab rooms. Configure the Labels field on EffectMesh to specify which anchor types to visualize. This sample visualizes all labels except GLOBAL_MESH. See the MRUK API reference for all configuration options.

Scene load event subscription

WorldLockTint.cs demonstrates the event-driven initialization pattern. In OnEnable, the script subscribes to the scene loaded event:
MRUK.Instance.SceneLoadedEvent.AddListener(OnSceneLoaded);
This callback fires when MRUK finishes loading scene data from the device or fallback source, signaling that room data is available for queries. For late subscribers after the scene has already loaded, use MRUK.Instance.RegisterSceneLoadedCallback(). See the MRUK class reference for event subscription patterns.

World lock monitoring

WorldLockTint.cs polls the MRUK.Instance.IsWorldLockActive property each frame to detect when the device loses or regains localization. When world lock becomes inactive, the script tints all EffectMesh renderers red:
foreach (var obj in GetComponent<EffectMesh>().EffectMeshObjects) {
    obj.Value.effectMeshGO.GetComponent<Renderer>().material.color = InactiveColor;
}
This provides immediate visual feedback that virtual objects are no longer aligned with the physical world. See WorldLockTint.cs for the complete implementation.

EffectMesh visualization

The EffectMesh prefab automatically generates mesh overlays for all anchors matching the configured Labels flags. The SpawnOnStart field controls timing (set to CurrentRoomOnly in this sample to generate meshes immediately for the active room). The EffectMeshObjects dictionary provides access to generated meshes at runtime for manipulation or querying. See the EffectMesh API reference for mesh generation options and cutout features.

Extend the sample

  • Modify the Labels field on the EffectMesh prefab in the Inspector to visualize only specific surface types. For example, set it to FLOOR and TABLE to highlight interactive surfaces.
  • Enable the CutHoles option for DOOR_FRAME and WINDOW_FRAME labels to create physically accurate openings in wall meshes.
  • Replace the default mesh material with a custom shader that responds to lighting or user interaction.
  • For room reskinning with custom prefabs, see the VirtualHome sample. For spatial queries on scene data, see the FloorZone sample.