Getting Started with Vuforia Engine and Magic Leap 2 – Alpha Support

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 ML Hub and install the ML SDKs for Unity and/or Native with the Package Manager. These are also available in the bundles.
  • Download and install the Unity Editor V. 2022.2.0b7 or higher 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 with the 2022.2.0b7 Unity version or higher and select 3D Universal Render Pipeline (URP) template.
  2. Follow the guide Magic Leap’s Import Unity Tools and add the Magic Leap Unity SDK package.
    • 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.

    • Proceed to Add package from Disk for the com.magicleap.unitysdk that you downloaded from ML Hub.

      This might prompt another warning 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 in the Project Settings -> XR Plug-in Management on the Android Platform.
    • Setting the Permissions in the Project Settings -> Magic Leap -> Manifest Settings. A generic Vuforia project requires the following permissions:

    • Configuring the Project Settings -> Player.
    • Configuring the Universal Rendering Pipeline (URP) settings.
    • 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.

Workarounds

  1. In the next pop-up asking you to add Vuforia Engine 10.10.X, click Cancel!
  2. Instead, locate in Assets/Editor/Migration the zipped package ptc.vuforia.engine-10.10.X.tgz and extract the contents by double-clicking the package.
  3. Delete the Assets/Editor/Migration/com.ptc.vuforia.engine-10.10.X.tgz file.
  4. In Finder or File Explorer, move the extracted content ‘package’ to the Packages folder in your Unity Project and rename it to com.ptc.vuforia.engine.

Workaround continued for MacOS

  1. On MacOS, three bundles will be marked damaged.
    • FileDriver.bundle
    • UnityDriver.bundle
    • VuforiaUnityPlayer.bundle
  2. To resolve these, open a terminal and do the following command for the package:
    xattr -r -d com.apple.quarantine <path to the com.ptc.vuforia.engine>

    TIP: The path would look like: /UnityProjectName/Packages/com.ptc.vuforia.engine

    If your Unity Project name is with spaces, use ‘ around the path.

Add the Camera 

  1. To set up your scene, replace the Camera with the Magic Leap Main Camera -> Prefab located in Packages/com.magicleap.unitysdk/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 Lumin 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 Lumin SDK from ML 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:
  • CONTROLLER_POSE
  • EYE_TRACKING
  • HAND_TRACKING
  • HEAD_POSE
  • SPATIAL_ANCHOR
  • SPATIAL_MAPPING
  • Add permissions in the Android Manifest with:
    <uses-permission android:name="com.magicleap.permission.CONTROLLER_POSE" />