Skip to main content
Version: 20 Jan 2025

How To Install The Magic Leap Spectator Unity Package

This section is for anyone adding Magic Leap Spectator functionality to their ML2 application. Adding the ML Spectator package to your Unity project will allow anyone running the ML Spectator app on their mobile device to stream the content from your application. This can help in unlocking new use cases and support the showcasing of your application as a whole.

Project Requirements

In order to import and utilize the ML Spectator Unity Package in your project, the following minimum project requirements must be met:

  • MLSDK ver 1.3.0 or later.
  • Universal Render Pipeline Ver 12.0.0 or later.
  • Unity 2022.2.5 or later.

How to install the ML Spectator Unity package using NPMJS

  • Add the Magic Leap registry to your Unity package manager by going to Edit > Project Settings > Package Manager

    Name: NPMJS Magic Leap URL: https://registry.npmjs.com Scope(s): com.magicleap

NPMJS Registry Fields
  • Click Save or Apply

Integrate into a Unity Project

To add the ML Spectator package to your Unity project, follow these steps:

  • Open the Unity Package Manager (Window > Package Manager).
  • Click the + icon and select Add package by name.
  • Type 'com.magicleap.spectator' in the 'Name' field and press Install
Install Package by Name
Install Package by Name Fields
  • Add the ML Spectator plugin to your project by selecting Magic Leap > Add ML Spectator to Project. This will add the basic ML Spectator utilities to your project. If you would like to have the ML Spectator with notifications, select Add ML Spectator with Notifications to Project. You do not need to add both. Either option will incorporate the required utilities, the notification option will simply also add the notification functionality.
  • This will automatically include the ML Spectator prefab into the first or currently open Unity Scene and set the com.magicleap.permission.MARKER_TRACKING and com.magicleap.permission.RECORD_AUDIO permissions in your build settings as they are required for ML Spectator to function.
tip

It is recommended that you change the product and package name in Edit > Project Settings… > Player to indicate that this version has the ML Spectator plugin installed.

Build & Run On Magic Leap 2 Headset

Before building the project, verify that the Auto Enable setting is checked in the ML Spectator prefab. This will ensure that the utilities will run when the project loads. For security purposes, it is suggested that in final builds the Auto Enable setting is not selected and that a UI opt-in option is presented. See Enabling ML Spectator Utilities for more information. In order for the ML Spectator prefab to function the ML Spectator utilities must be included in the first loaded scene in the project. Open the build menu and verify that the scene with the ML Spectator utilities is first in the Scenes in Build list. Build the ML2 application as usual and run the app on the ML2 headset.