Getting Started with Vuforia Engine and Magic Leap 2

Set up Vuforia Engine and Magic Leap 2 to track and develop experiences that detect and track physical images and objects on their latest device.

Prerequisites

Set up your development environment by following Magic Leap’s setup guides.

  • Download Magic Leap Hub and install the Magic Leap SDKs for Unity and/or Native with the Package Manager. These are also available in the bundles.
  • Make sure to download ML C SDK 1.1.0 or higher, and Unity Package 1.3.0 or higher.
  • Download and install the minimum supported Unity Editor version or newer with the Android Build Support and its dependencies: Android SDK & NDK Tools and OpenJDK.

See Setting up Vuforia Engine and Magic Leap 2 in Android Studio for native.

Refer to the Supported Versions page for details on the operating systems that are supported by the Vuforia SDK.

Set up a New Scene in the Unity Editor

  1. Create a new project and select the 3D template using Unity’s built-in renderer.
  2. Follow the guide Magic Leap’s Import Unity Tools and add the Magic Leap Unity SDK package. You might see the following warning pop-ups:
    • A warning might appear regarding a new input system and ask you to enable the backends. You can click Yes which will restart the Unity Project.
    • Another warning might pop up asking if you want to proceed. You can click ‘I Made a Backup, Go Ahead!’.
    • In the Unity -> Preferences, set the External Tools -> Magic Leap to the path where your …/MLSDK/<Version> resides.
  3. Go to Magic Leap’s Configure Project Settings and edit the Project Settings and Player Settings accordingly. This includes:
    • Enabling Magic Leap under Plug-in Providers for the Android Platform in the Project Settings -> XR Plug-in Management.
    • Enabling a custom manifest in your project's settings by going to Edit -> Project Settings -> Player, then under Publishing Settings select Custom Main Manifest under Build.
    • Setting the Permissions in the Project Settings -> Magic Leap -> Permissions. A generic Vuforia project requires the following permissions:
      • CAMERA
      • SPATIAL_MAPPING
      • SPATIAL_ANCHOR
      • RECORD_AUDIO only required if you plan to record audio with the SessionRecorder.

        NOTE: In your project’s app code, make sure to request the “com.magicleap.permission.SPATIAL_MAPPING” permission at runtime. See Magic Leap’s Requesting Permissions on how to do this.

    • Configuring the Project Settings -> Player Settings and Build Settings according to Magic Leap’s Configure Project Settings page.
    • Switching the Build Platform to Android.

Add Vuforia Engine

  1. Download the Vuforia Engine package for Unity from the Developer Portal or via Unity’s Package Manager.
  2. Double-click or drag the downloaded package into the Unity Project Asset window. Click Import.
  3. In the next pop-up asking you to add Vuforia Engine, click Update.

Add the Camera 

  1. To set up your scene, replace the Camera with the Magic Leap Main Camera -> Prefab located in Packages/Magic Leap SDK/Runtime/Tools/Prefabs/Main Camera.prefab.
  2. Proceed to add the following components to the Magic Leap Main Camera GameObject.
    • Vuforia Behaviour
    • Default Initialization Error Handler

  3. Add Vuforia's Image Target feature to the project. Go to GameObject -> Vuforia Engine and select Image Target.
  4. Add a Cube GameObject as a child to the ImageTarget GameObject.
  5. Save the project and save the scene.
  6. Go to File -> Build and Run. This should compile and install the APK file on your Magic Leap 2 device provided it is connected. See Building to Device for more information.

Setting up Magic Leap 2 and Vuforia Engine in Android Studio

Develop AR experiences for Magic Leap in Android Studio using the Vuforia Engine and the Magic Leap SDK. Set up Android Studio and your Magic Leap 2 device and add the Vuforia Engine Lumin SDK package.

  1. Set up your Android Studio project following Magic Leap’s setup guide. The setup includes the Chipmunk version of Android Studio and specific versions of Android SDK Tools, Android NDK, CMake and platform API level.
  2. Next, add the Magic Leap SDK to the Android Studio project following Magic Leap’s Android Studio Workflow guide. This includes getting the Magic Leap SDK from the Magic Leap Hub, adding their ml-addon.xml to the Android SDK Update Sites list in the SDK Manager and downloading their SDKs.
  3. Add the Vuforia SDK package to the project. Download the Vuforia SDK for Lumin and add the Vuforia Engine library to the Android Studio project.
  4. Lastly, make sure to have the necessary permissions for using Vuforia Engine and Magic Leap in the Android Manifest.

    See Vuforia Engine Native Lifecycle and Declaring Permissions for details on adding permissions. Specifically, Magic Leap requires the following permissions enabled:

  • CAMERA
  • SPATIAL_ANCHOR
  • SPATIAL_MAPPING
  • RECORD AUDIO - only  required if you plan to record audio with the SessionRecorder.
  • Add permissions in the Android Manifest with:
    <uses-permission android:name="com.magicleap.permission.SPATIAL_ANCHOR" />

NOTE: Make sure to include startup of the Magic Leap Perception system by calling MLPerceptionStartup during initialization and before VuEngineCreate(). Clean up processes on exit by calling MLPerceptionShutdown.

Can this page be better?
Share your feedback via our issue tracker