Configure Existing MRTK 3 Project
This guide demonstrates how to add Magic Leap 2 support to an existing MRTK 3 Project. Visit the Magic Leap MRTK 3 Overview page to learn about the features currently supported on Magic Leap 2.
Prerequisites
Before starting, download or install the following packages and tools:
- From the Magic Leap Hub download:
- Magic Leap SDK v1.2.0 (or later)
- Magic Leap Unity SDK v1.6.0 (or later)
- Magic Leap MRTK 3 1.0.0-pre.5 (or later)
- Download and install a Unity Editor v2022.2.x
Import MRTK3 Magic Leap
After importing the MRTK3 packages, import the MRTK3 Magic Leap package into the project.
- Download the MRTK3 Magic Leap package using the Magic Leap Hub's Package Manager.
- Open the Package Manager (Window > Package Manager), select the + icon, then select Add package from tarball....
- Import the
com.magicleap.mrtk3-[VERSION].tgz
(version 1.0.0-pre.5 or higher) package fromMagicLeap/tools/unity/mrtk3/
.
Configure MRTK profile
- OpenXR Provider
- MLSDK Provider
OpenXR Provider Setup
If the project contains the com.unity.xr.openxr package (version 1.9.1 or later), you can use the OpenXR
XR plugin. Follow the below steps to setup the MRTK3 project to run properly with this XR Provider.
The following packages and their minimum versions are required to use OpenXR on Magic Leap 2 with MRTK3:
- com.magicleap.unitysdk version 2.0.0 (or later)
- com.unity.xr.openxr version 1.9.1 (or later)
- com.unity.xr.hands version 1.4.0-pre.1 (or later)
Bring up project settings (Edit > Project Settings).
Within project settings, go to the XR Plug-in Management category on the left.
- Select the
Android
settings tab. - Select the
OpenXR
provider in the list. Make sure this is the only selected XR Provider for Android.- Select the
Magic Leap Feature Group
.
- Select the
- Select the XR Plug-in Management > OpenXR category on the left for more options.
- Set the Depth Submission Mode to
None
. - Make sure the following interaction profiles are added:
Magic Leap 2 Controller Interaction Profile
Eye Gaze Interaction Profile
Hand Interaction Profile
- In the feature list, make sure the
Magic Leap 2 ...
features you want are selected, plus Unity'sHand Tracking Subsystem
feature. - Recommendation: Change the OpenXR Blend Mode from
Alpha Blend
toAdditive
so the Segmented Dimmer is disabled default.- Select the
Magic Leap 2 Rendering Extension
settings icon. Set Blend Mode toAdditive
.
- Select the
- Set the Depth Submission Mode to
- Select the
Within project settings, go to the MRTK3 category on the left.
- Set the Profile to MRTKProfile-MagicLeap, found at
Packages/com.magicleap.mrtk3/Runtime/XRProviders/MagicLeap/Configuration/Default Profiles/
.
- Set the Profile to MRTKProfile-MagicLeap, found at
If Microsoft's OpenXR package is also in the project, make sure the Hand Tracking
feature is disabled inside the OpenXR Feature Groups. This feature is deprecated and will cause the application not to load properly.
MLSDK XR Provider Setup
If you are using the legacy MLSDK and XR workflow, make sure your project contains the com.unity.xr.magicleap package. Afterwards follow the below steps to set the MRTK3 profile to MRTKProfile - MagicLeap. This profile adds Magic Leap 2 support to the MRTK XR Subsystems.
- Open the Project Settings window (Edit > Project Settings).
- Within Project Settings, select MRTK3 from the sidebar then the Android tab.
- Set the Profile to MRTKProfile-MagicLeap, found at
Packages/com.magicleap.mrtk3/Runtime/XRProviders/MagicLeap/Configuration/Default Profiles/
.- If the profile does not appear in the asset window, click the small "eye" icon located at the top-right corner of the menu to reveal hidden items in the list of assets.
- You can find the profile under
Packages/com.magicleap.mrtk3/Configuration/Default Profiles/MRTKProfile-MagicLeap.asset
.
- Configure the MRTK XR Rig to be compatible with Magic Leap 2 input (2 provided options).
- First option: Use the Runtime MRTK XR Rig Configuration option in settings.
- Within project settings, go to the MRTK3 > Magic Leap Settings category on the left.
- Make sure the
Magic Leap
option is selected for Settings for XR Provider: at the top to view specific settings for the Magic Leap XR Provider. - Check the
Runtime Rig Config Enabled
checkbox at the top of the Runtime MRTK XR Rig Configuration window.- Enabling this feature will allow the default MRTK XR Rig to work with ML2 input without needing to modify the scene.
- Second option: In your scenes, remove and replace the default MRTK XR Rig with the
MRTK XR Rig - MagicLeap
prefab variant located inPackages/com.magicleap.mrtk3/Runtime/XRProviders/MagicLeap/Prefabs/MRTK_Variants/
.
- First option: Use the Runtime MRTK XR Rig Configuration option in settings.
Permissions
Hand Tracking and Eye Tracking requires developers to add additional permissions to your project's Manifest. To add the additional permissions follow the steps below:
- Go to the Magic Leap Permissions Settings (Edit > Project Settings > Magic Leap > Permissions)
- Enable com.magicleap.permissions.HAND_TRACKING
- Enable com.magicleap.permissions.EYE_TRACKING
For more information, refer to the Magic Leap 2 permissions guide.
The Magic Leap MRTK 3 package offers Runtime Permission Configuration in project settings to auto request and/or start certain permission easily without needing to add prefabs or code to your scenes to do so. Permission can be setup to be auto requested/started in (Edit > Project Settings > MRTK3 > Magic Leap Settings > Runtime Permissions Configuration).
Magic Leap Rig
The following section includes information about creating a Magic Leap ready scene using MRTK3.
- Runtime Configuration
- MRTK XR Rig Prefab
Enable Runtime Configuration
To support the standard rig, the MRTK Magic Leap package includes a feature that automatically configures the MRTK XR Rig prefab. This section includes information on how to enable the Runtime configuration feature. To learn more about the Magic Leap specific settings, visit the MRTK 3 Magic Leap Settings guide.
- Navigate to the Magic Leap Settings Window by going to Edit > Project Settings then MRTK3 > Magic Leap Settings.
- Enable the Runtime Config Enabled setting.
Using the MRTK XR Rig - MagicLeap prefab
This section includes instructions on creating a new scene using the MRTK XR Rig - MagicLeap prefab. This prefab is pre-configured required to support Magic Leap Input such as hands, controller and gaze. Alternatively, you can use the runtime configuration feature which will allow you to use the standard MRTK3 rig.
- Remove the MRTK XR Rig Game Object it one exists as it will be replaced with the one supported by Magic Leap,
- Add the MRTK XR Rig - MagicLeap - OpenXR prefab.
- The prefab can be found in your Project folder in the
Packages/com.magicleap.mrtk3/Runtime/XRProviders/OpenXR/Prefabs/MRTK_Variants/
directory.
- The prefab can be found in your Project folder in the
If you are using the legacy Magic Leap XR Workflow, use the MRTK XR Rig - MagicLeap prefab instead, which is located under Packages/com.magicleap.mrtk3/Runtime/XRProviders/MagicLeap/Prefabs/MRTK_Variants/
.
There is a known bug which causes builds of the MRTK3 dev template project to fail only when selecting Build and Run on a Mac. To mitigate this, select Build to build the apk and manually install it to the device.