Magic Leap Spectator
Magic Leap Spectator (ML Spectator) is a mobile application that makes it easy for anyone to capture and share high quality mixed reality content streamed from a Magic Leap 2 device. This powerful application supports a wide variety of use cases, for example:
- Creating video documentation of your Magic Leap 2 applications.
- Creating second-screen experiences for demos.
- Filming “how-to” videos for your ML2 applications.
- Broadcasting your ML2 application content live to audiences at events.
- ML Spectator allows you to record your digital content as videos or photos so you can share and/or process them later on.
For more information about Magic Leap Spectator, see the Magic Leap Spectator Guide in the Customer Care portal.
The rest of this page explains how to make your Magic Leap 2 Applications Spectator compatible.
Make Your Magic Leap 2 Applications Spectator Compatible
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.
Prerequisites
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
Download the Latest Unity Package
You can download the latest ML Spectator Unity Package via the Magic Leap Hub.
- Navigate to Package Manager > Unity Packages
- Search for Magic Leap Spectator Unity Package.
Import the Package
Once the Magic Leap Spectator Package has been downloaded, it can be imported into your project via Unity's Package Manager.
Inside your Unity project, open the Unity Package Manager (navigate to Window > Package Manager).
Click the + icon and select Add package from tarball.
Locate the ML Spectator Unity package in the file browser and click Open.
Integrate Into a Unity Project
After importing the package, configure your scene and project for Magic Leap Spectator.
From the top menu, select one of the Magic Leap > Add ML Spectator ... options to import ML Spectator components into your scene.
- Select Magic Leap > Add ML Spectator to Project to include basic ML Spectator utilities.
- Select Add ML Spectator with Notifications to Project to also incorporate notification capabilities. (It's not necessary to select both; either option includes the essential utilities.)
Verify that the option executed successfully
- Verify that the MLSpectator prefab was added into your Unity Scene
- Check your the Magic Leap Permissions to ensure both the
com.magicleap.permission.MARKER_TRACKING
andcom.magicleap.permission.RECORD_AUDIO
permissions were added.
Enable Magic Leap Spectator Feature Automatically
- Make sure that the Auto Enable setting is checked in the MLSpectator 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.
Build & Run On Magic Leap 2 Headset
To deploy your project on the Magic Leap 2 headset, follow these steps:
- [Optional] Change the product name and package name in Edit > Project Settings… > Player to indicate that this version has the ML Spectator plugin enabled.
- Build Configuration
- Open the Build Settings
- Inside the Scenes in Build list, verify that the scene containing the MLSpectator prefab is present and the first scene in the list.
- Build the ML2 application as usual and run the app on the ML2 headset.
Best Practices and Troubleshooting
Including ML Spectator Prefabs in Scenes
The ML Spectator prefab only needs to be included once in your project. Even if your project has multiple scenes, you only need one instance of the prefab, however in order to ensure that the ML Spectator utilities function from launch the prefab must be included in the first scene that is loaded when your application starts up. Once the prefab has been called it will keep running until the application is closed. There is no need to include the prefab in every scene loaded as the utilities are inherited between scenes and not destroyed when changing scenes or application states.
Enabling ML Spectator Utilities
By default the ML Spectator utilities are not enabled. Within the inspector, on the ML Spectator prefab there is an option for Auto Enable. It is suggested that this option not be selected for public builds. To enable ML Spectator at runtime include a toggleable UI element to call MLSpectator.Instance.Enable()
and MLSpectator.Instance.Disable()
. There is also a toggle function available MLSpectator.lnstance.Toggle()
. If Auto Enable is used you should include a privacy notification that ML Spectator is active and that a session could be joined and recorded.
Special Lighting Modes
If the scene uses a single light attached to the Main Camera prefab in order to light the scene then ML Spectator may display the AR content with inconsistent lighting. In this case enable the Control Scene Lights option in the MLSpectator prefab. However, if your application lights the scene globally or with baked-in lights as a part of the scene then ML Spectator will function and display the AR content as expected.
ML Spectator viewer lens prefab when controlling special scene lighting Inside of the MLSpectator prefab is an option for a “lens” prefab which represents the lens of the camera of the mobile device which is connected in a session. This can be used via the ML2 headset user to diagnose how well the synchronization is when connected. It is very small and otherwise unneeded and does not need to be disabled or changed. However, if the option Control Scene Lights is enabled this prefab is required as the prefab includes a light which takes the place of the Main Camera light when rendering AR content to display on the mobile device.
In Editor Preview
There is an option to preview the ML Spectator view from within the Unity editor for debug purposes. Normally this will not cause any interactions with a built project when running. However, if your project is designed to be controlled via the editor when running on the ML2 headset this option will interrupt the displayed scene when entering Play mode. In order to avoid this interaction, disable this option in the prefab settings.
Render and Quality Options
It is recommended that you use the Performant Quality setting in your project settings to reduce visual artifacts. Whatever quality settings are selected, ensure that the URP is the render pipeline selected.
Can the ML Spectator utility work in the editor?
Yes, the ML Spectator plugin is functional in the editor on Windows and Mac computers. For best experience make sure that the editor can run in the background. This can be done by checking Edit > Project Settings… > Player > Settings for Windows, Mac, Linux > Resolution and Presentation > Run In Background.
FAQs
Which iPhone devices are supported?
Any iPhone device capable of running iOS 17.
I receive the message: "Network Error": "Connection is not strong enough to support the application.". What does this mean?
There seems to have been a significant delay in the network that was hindering the experience. It is recommended to use a 5GHz Wi-Fi connection, preferably with a dedicated router in line of sight of both devices. If the problem persists, it is possible your phone model or version are unsupported.
The virtual content does not line up well with the ML2 headset wearer.
Try the marker detection again. Place the marker as close to the location of the ML2 user as possible (the marker can be moved after colocation is succeeded). Make sure the marker size is 15cm ( 5.91 inch ) wide. Hold the phone and ML2 at a shallow angle to the marker, when scanning it for the best detection. For better tracking also avoid scanning the marker too closely, scanning from a distance with more features visible and on a non-blank surface is better.