Install the Tools
This section provides information on how to install and configure the Unity Editor required to develop for Magic Leap 2.
When running a project, if an error similar to the below appears in the Unity error console, additional runtimes ("Workloads") may need to be installed, supplied by Microsoft:
Plugins: Failed to load 'C:/AppDirectory/Library/PackageCacheemail@example.com/Plugins/x86_64/AudioPluginMSASpatializer.dll' because one or more of its dependencies could not be loaded.
Microsoft Visual C++ Redistributable latest supported downloads.
Install Magic Leap SDK & Tools
We'll use the ML Hub to install and manage the Magic Leap Unity Package, the Unity SDK Examples Project, and other tools.
Open the ML Hub Package Manager
To access the Package Manager in the ML Hub:
- Open the ML Hub.
- Select Package Manager from the home screen.
Downloading the Unity Bundle
To download the Unity Magic Leap Examples Project from the bundle section:
- Select the Unity - 3D Creation Bundle.
- Next, select any additional package. We recommend that you include all the additional packages listed in the Change Summary section.
- Click Apply Changes.
Install Unity Editor
This section describes the process of installing the Magic Leap 2 compatible Unity Editor. Developers are able to develop Magic Leap 2 applications with any Unity Editor in the range of 2022.2.x.
- Open the Unity Hub application
- Select the Installs
- Then click the Install Editor button.
- With the Install Unity Editor window open, navigate to the Pre-releases section
- Select a Unity Editor that is in the range of 2022.2.x
- In the modules screen select Android Build Support, then Android SDK & NDK Tools, and OpenJDK.
- Select the Continue button.
Magic Leap Hub Interaction
The following instructions only need to be performed if you are experiencing issues connecting and deploying to your device. Device communication can be incorrectly terminated when conflicting versions of ADB are being used. To correct this, you can set the Magic Leap Hub's ADB installation path to the one used by the Unity Editor.
- Open the Magic Leap Hub.
- Open the Magic Leap Hub's Developer Settings ( Home > Settings > Magic Leap Hub > Developer)
- Select Use custom adb and set the path to the Android Tools used by Unity.
If you are unsure which SDK path is used by your Unity installation, you can view the Android SDK path used by the Unity Editor inside Unity's Preferences Window.
- In Unity, select Edit > Preferences (macOS: Unity > Preferences).
- In the left navigation column, select External Tools. The Android section of the External Tools panel contains entries for JDK, SDK, NDK, Gradle.
- Copy the SDK path, then set the custom adb path inside the Magic Leap Hub to this location. Note, the adb service will be located in the SDK's
- Finally, disable the Kill ADB server on exit, unless you need this behavior. By default, the preference is active, which can cause disruptions when using the Magic Leap Simulator.
Create a Unity Project
Learn which version of Unity and the project template to use when creating a new Magic Leap 2 application.
Unity Examples Project
After successfully creating a new application, check out the pre-configured Magic Leap Unity Examples Project to see some of Magic Leap's unique platform features.
Magic Leap App Simulator
The Magic Leap App Simulator can be used to test applications much faster, without deploying them to the physical device. See our Magic Leap App Simulator for Unity section to learn how to configure your unity settings to run applications in the Simulator.