Skip to main content
Version: 10 Jul 2024

Set Up MRTK for Magic Leap 2

Current Status

Eye TrackingRelease
Hand TrackingRelease
Voice CommandsRelease

MRTK 2.8 SDK and Package Compatibility

ML2 Unity SDKMagic Leap XR PackageOpenXR Package
2.0.0 or higherSupportedUnsupported

Developers that are developing with MRTK 2.8 are advised to use Magic Leap Unity SDK 1.12.0.



If updating to Magic Leap Unity SDK 1.10.0 - 1.12.0, there may be a compile issue if your project contains the Unity OpenXR package. A workaround for this is to remove the OpenXR package from the project in this situation.

Getting Started

Configure Your Project

  1. In Player Settings set the Active Input Handling to Both. Restarting the editor may be required.
  2. Import the TMP Essential Resources by selecting Window > TextMeshPro > Import TMP Essential Resources.
  3. Open the Unity Preferences window and set the Script Changes While Playing setting to Stop Playing and Recompile or Recompile and Continue Playing.
  4. Install Universal RP from the Package Manager and set a UniversalRenderPipelineAsset in the Graphics Settings
  5. Make sure Custom Main Manifest is selected under Publishing Settings so MagicLeap Manifest Settings can be set.

Import MRTK

  1. Download version 2.8 of MRTK Foundation and MRTK Examples from the MRTK GitHub.
  2. Import the MRTK Foundation 2.8 package into your Unity project. Apply the recommended settings from the popup window that appears after doing so.
  3. It will ask for Script Updating Consent, select Yes, for these and other files that might be found later.
  4. Next, import the MRTK Examples 2.8 package into your project. Note: Some Oculus prefabs may log an error, these can be cleared.
  5. Note that the MRTK Tools package is now required for future upgrading to a newer version of MRTK according to the releases page linked to in #1.
  6. From the top menu Select Mixed Reality > Toolkit > Utilities> Upgrade MRTK Standard Shader for Universal Render Pipeline. This will be greyed out unless a URP pipeline asset is set in the Graphics Settings

Edit MRTK Standard Shader

The standard shader in MRTK (MixedRealityStandard.shader) may trhow an error or warning message in the log when building in Unity v2022.2 or higher. To resolve these, make the following changes to the MixedRealityStandard.shader shader file.

  1. Change line 775 from fixed facing : VFACE to bool facing : SV_IsFrontFace
line 775
+            fixed4 frag(v2f i, bool facing : SV_IsFrontFace) : SV_Target
- fixed4 frag(v2f i, fixed facing : VFACE) : SV_Target
  1. Change line 956 from * facing; to * (facing ? 1.0 : -1.0)
line 956
+                worldNormal = normalize(worldNormal) * (facing ? 1.0 : -1.0)
- worldNormal = normalize(worldNormal) * facing;
  1. Change line 959 from * facing; to * (facing ? 1.0 : -1.0)
line 959
+                worldNormal = normalize(i.worldNormal) * (facing ? 1.0 : -1.0)
- worldNormal = normalize(i.worldNormal) * facing;

Import MRTK Magic Leap 2

  1. Download the MRTK Magic Leap 2 Unity Asset using the ML Hub Package Manager.
  2. Import the asset into your project by going to Assets > Import Package > Custom Package and selecting the MRTK Magic Leap Unity package, located under USER / MagicLeap / tools / unity / mrtk / VERSION / directory.

MRTK Magic Leap 2 Examples

You can test the MRTK Magic Leap 2 implementation using the Example scenes located under MRTK-Magic Leap 2/Samples/

Make sure the MixedRealityToolkit's configuration profile is set to MagicLeap2 ...


Configure Hand Tracking Settings

The Magic Leap Hand Tracking Input Provider and Magic Leap Device Manager Input Provider can be configured to dynamically switch between controller and hand input devices.

However, if you need to override or edit this behavior you can use the following settings:

Settings for Disabling Controller

Track a Single Hand

Developres can choose to track a single hand. This can be done by setting the following changing MagicLeapHandTrackingInputProvider CurrentHandSettings property.

MagicLeapHandTrackingInputProvider.Instance.CurrentHandSettings = MagicLeapHandTrackingInputProvider.HandSettings.Left;

Disable Hand Tracking

Hand tracking can be disabled by setting the MagicLeapHandTrackingInputProvider's CurrentHandSettings to HandSettings.None or remove the Magic Leap Hand Tracking Provider from the MRTK input providers

MagicLeapHandTrackingInputProvider.Instance.CurrentHandSettings = MagicLeapDeviceManager.HandSettings.None;