Skip to main content

185 docs tagged with "Unity"

View All Tags

Anchors

An overview of the Anchors example scene which utilizes the Spaces application.

API Overview

This guide provides a comprehensive overview of the MLSpace API, specifically focusing on the key features and functions used to manage MLSpaces in your applications. It covers topics such as subscribing to the OnLocalizationEvent to monitor localization status changes, fetching available spaces, understanding and getting localization results, localizing into a specific space, and the export and import of spaces. Each topic is explored with detailed explanations and illustrative code snippets, aiming to provide a clear understanding of how to leverage the LocalizationMap effectively. The guide offers insights into the usage of key structs, values, and enums, enhancing your ability to create more interactive and responsive applications using MLSpaces.

API Overview

This guide provides a walk through of creating a custom camera capture script. The sections in this guide were written in a linear flow although each section can also be referenced individually.

API Overview

Magic Leap's Eye Tracking data is retrieved in two ways.

API Overview

This section provides information on the Gesture Classification API and how to enable it inside your application.

API Overview

This guide provides detailed instructions and examples on how to use the MagicLeap's MLPowerManager API for managing power states and properties of components in Unity. The guide first explains the concept of power states, showing how to get all available states and retrieve a specific state for a device. It then delves into the process of setting a power state with thorough examples. The guide proceeds to explain how to get and update the properties of a component, focusing on different aspects like battery info, battery level, charging state, and connection state. Lastly, it touches on how to handle power management events such as errors, state changes, and property changes through callbacks. By following this guide, developers can efficiently control and manage Magic Leap 2's power states and properties inside their Unity Application.

API Overview

This guide provides a comprehensive overview of the MLSpace API, specifically focusing on the key features and functions used to manage MLSpaces in your applications. It covers topics such as subscribing to the OnLocalizationEvent to monitor localization status changes, fetching available spaces, understanding and getting localization results, localizing into a specific space, and the export and import of spaces. Each topic is explored with detailed explanations and illustrative code snippets, aiming to provide a clear understanding of how to leverage the MLSpace API effectively. The guide offers insights into the usage of key structs, values, and enums, enhancing your ability to create more interactive and responsive applications using MLSpaces.

App Simulator

This document demonstrates how to use the MagicLeapXrProvider to check if the application is using the Magic Leap App Simulator.

Audio

This section provides information on using Magic Leap 2's Audio API for audio input and output.

Audio Capture

An overview of the audio capture demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Audio Change Events

This section provides an example script that demonstrates how to subscribe to Magic Leap's Audio change events.

Audio Input

This section provides examples of how to use Magic Leap's APIs to record audio.

Battery Intents

This section demonstrates how to collect battery information from the Magic Leap 2's Compute Pack and Controller in Unity. See the Android Intents Overview guide for information regarding the native implementation.

Camera Capture

An overview of the camera capture demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Camera2

The Magic Leap 2 supports the Android Camera2 NDK APIs. With Android Camera allows developers to capture real and virtual content inside their applications. While the Magic Leap 2 has only one physical, it is presented as 3 separate devices in the API. The Main Camera (Camera Id 0) and Mixed Reality Camera (Camera Id 3) are mutually exclusive, however they can be accessed even while the CV Camera (Camera Id 1) is being used.

Configure Project Settings

This section provides detailed steps on how to manually configure your Unity Project so that you can build and deploy OpenXR applications for Magic Leap 2.

Controller

An overview of the controller demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Controller Input Events

This section demonstrates how to use Unity's Input System to access input events from the Magic Leap 2 controller.

Controller Overview

Unity developers can use the OpenXR Magic Leap 2 Controller Interaction Profile to access the controller's input using Unity's Input system. This profile can be enabled inside your project's OpenXR Settings Window > XR Plugin Manager > OpenXR Settings

Create a Project

This section provides instructions on creating a new Unity with a version that is compatible with Magic Leap 2 development.

Create a Project

This section provides instructions on creating a new Unity with a version that is compatible with Magic Leap 2 development.

Custom Fit

An overview of the Anchors example scene which utilizes the Spaces application.

CV Camera

An overview of the cv camera demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Deploying Custom Voice Commands

The Magic Leap 2 Voice Input framework supports App Specific Voice Intents which are custom voice intents you can develop to use within your app. You can develop a full set of voice intents to incorporate in your applications with the assistance of the Voice Intent Development ToolKit (VIDTK).

Display Overview

Learn various tools to enhance the way Magic Leap 2 displays content.

Error Reporting

If you are experiencing issues with the Magic Leap App Simulator, let us know so we can help you get up and running. The App Simulator package makes it easy for users to save all of the diagnostics logs.

Examples

This section demonstrates how to use the Gesture Classification API.

Explicit Intent Example

Explicit intents specify which application will satisfy the intent, by supplying either the target app's package name or a fully-qualified component class name. Explicit Intents can also be used to pass data to other activities.

Eye Gaze Overview

Unity developers can use the OpenXR Eye Gaze Interaction Profile to determine what a user is looking at, allowing a hands-free method of interacting with their application. To access the Eye Gaze data, the interaction profile needs to be enabled in your project's OpenXR Settings (Window > XR Plugin Manager > OpenXR Settings).

Eye Tracking

An overview of the eye tracking demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Eye Tracking Overview

If your Application collects, stores, transfers or otherwise uses data off the Magic Leap 2 device that is received via this API, then you must comply with the Magic Leap 2 Eye Tracking Data Transparency Policy.

Eye Tracking Tracked Pose Driver

If your Application collects, stores, transfers or otherwise uses data off the Magic Leap 2 device that is received via this API, then you must comply with the Magic Leap 2 Eye Tracking Data Transparency Policy.

Eye Tracking Tracked Pose Driver

If your Application collects, stores, transfers or otherwise uses data off the Magic Leap 2 device that is received via this API, then you must comply with the Magic Leap 2 Eye Tracking Data Transparency Policy.

Generic Eye Tracking Data

If your Application collects, stores, transfers or otherwise uses data off the Magic Leap 2 device that is received via this API, then you must comply with the Magic Leap 2 Eye Tracking Data Transparency Policy.

Gesture Classification

An overview of the gesture classification demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Getting Started

These guides serve as a starting point for Magic Leap app development in Unity using OpenXR. If this is your first time developing for Magic Leap, we recommend that you follow the guides sequentially. If you are an experienced Magic Leap developer, these guides can be used as standalone references.

Getting Started

This section includes information on how to detect if an application is running on a Magic Leap 2 in addition to checking if a developer is most likely building for Magic Leap 2.

Getting Started

These guides serve as a starting point for Magic Leap app development in Unity. If this is your first time developing for Magic Leap, we recommend that you follow the guides sequentially. If you are an experienced Magic Leap developer, these guides can be used as standalone references.

Global Dimmer

An overview of the Global Dimmer example scene which showcases global dimming range.

Global Dimming

Learn how to use the Magic Leap 2's unique global dimming technology.

Global Dimming

Learn how to use the Magic Leap 2's unique global dimming technology.

Hand Tracking

An overview of the hand tracking demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Hand Tracking Overview

The Magic Leap 2 OpenXR Unity SDK supports hand tracking via the Hand Interaction Profile. The interaction profile can be enabled by selecting Edit > Project Settings > XR Plug-in Management > OpenXR, then adding the interaction profile into the Enabled Interaction Profiles section.

Hand Tracking Overview

This section provides information on the core Hand Tracking API and how to enable it inside your applications.

Handling Tracking Loss Events

If the Magic Leap can't locate its position in an environment, it experiences "tracking loss". The Magic Leap 2 lets developers manage their own tracking loss behavior -- some developers may want to pause the update loop and display a splash image, while others may want the app to continue playing.

Handling Tracking Loss Events

If the Magic Leap can't locate its position in an environment, it experiences "tracking loss". The Magic Leap 2 lets developers manage their own tracking loss behavior -- some developers may want to pause the update loop and display a splash image, while others may want the app to continue playing.

Haptics

An overview of the Haptics example scene.

Hello Cube

An overview of the hand tracking demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Implicit Intent Example

Implicit Intents do not directly specify the Android components which should be called, it only specifies an action to be performed. This allows a component from another app to handle the action request. For example, you may want to prompt the user to perform eye-tracking calibration.

Input Bindings

Unity's Input System can locate Controls using paths. Bindings on Input Actions utilize this feature to identify the Control(s) they receive input from. You can also use paths to directly look up Controls and Devices, or to have the Input System search for Controls among all devices using the InputSystem.FindControls method.

Input Bindings

This guide provides information on the input paths that are supported on Magic Leap 2 when using the OpenXR Eye Gaze Interaction Profile. For general information about OpenXR input in Unity, see the Unity OpenXR Plugin Input Manual.

Input Bindings

This guide provides information the Input Control Paths and Interaction Profiles that are supported on Magic Leap 2. For general information about the OpenXR Hand Interaction Profile in Unity. See the Unity OpenXR Hand Interaction Input Manual.

Input Device Feature Values

It is recommended that developers read the controller input using Unity's Input System. However, developers can obtain the controller's input directly from the InputDevice. This section provides an example of reading input using the TryGetFeatureValue method and XRCommonUsages features.

Input Device Feature Values

It is recommended that developers use the Unity Input System to obtain the Gaze Input. However, developers can also obtain eye tracking input directly from the InputDevice. This section provides an example of how to read input using the TryGetFeatureValue method and EyeTrackingUsages features.

Input Device Feature Values

It is recommended that developers read the controller input using Unity's Input System. However, developers can obtain the controller's input directly from the InputDevice. This section provides an example of reading input using the TryGetFeatureValue method and XRCommonUsages features.

Inputs Sample

This section describes how to read Magic Leap 2's controller input using Unity's Input System and Input Actions. The samples in this category assume that you are using the MagicLeapOpenXRInput.inputactions asset provided in the Magic Leap Samples. However, they can be easily modified to support custom input actions.

Install the Tools

This section provides information on how to install and configure the Unity Editor required to develop for Magic Leap 2.

Install the Tools

This section provides information on how to install and configure the Unity Editor required to develop for Magic Leap 2.

Intents

Unity developers can use intents inside their applications to open external activities and services. For example, you can use Intents to open the Eye Calibration application after detecting poor accuracy when using the Eye Tracking feature, or if you want the user to localize into a map before loading the content from your application. This section provides examples of how to call both implicit and explicit intents.

Intrinsic/Extrinsic Parameters

This section includes details on reading the Intrinsic and Extrinsic parameters from the Magic Leap camera. These values can be queried using the MLCamera.ResultExtras value provided in the Camera Capture callbacks.

Localization Map Examples

These scripts demonstrate various functionalities of the OpenXR Localization Map Feature, which is used for managing spaces in a mixed reality environment. The scripts are broken down into specific functionalities: requesting permissions, retrieving available spaces, localizing into a space, exporting and saving spaces, and importing previously saved spaces. Each script serves as an isolated example of a particular functionality, making it easier to understand and implement these functions in your own projects. They are designed to be used with the Unity game engine and the Magic Leap platform. Note that they should be used in a real device environment for proper functioning.

Localization Map Overview

The Magic Leap OpenXR Localization Map Feature allows developers to manage Spaces inside their application. This includes functionality such as querying a list of spaces, requesting localization into a specific Space and importing/exporting on device Spaces.

Magic Leap Eye Tracking Data

To obtain Magic Leap device specific features such as checking the eye tracking FixationConfidence status or if the user is blinking use Magic Leap's InputSubsystem.Extensions

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:

Marker Tracker API Overview

This section provides an overview of the marker tracker and references to create a custom Marker Tracking script.

Marker Tracker Events Example

The Magic Leap 2's marker tracker API is light weight and can be extended depending on your application's needs. This section provides an example of extending the API to broadcast an event when a marker is found, lost or updated based on the amount of time that has passed since the marker was update.

Marker Tracker Example

This section includes an example of detecting Fiducial Markers on the Magic Leap 2 headset.

Marker Tracking

An overview of the marker tracking demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Media Player

An overview of the media player demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Meshing

Learn how to create meshes from surfaces detected by the Magic Leap.

Meshing

An overview of the meshing demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Meshing Overview

This section details how to use Magic Leap 2's Meshing Subsystem Support feature in Unity. This feature allows applications to access a mesh that represents real-world geometry. Unity's mesh manager. Developers can use Unity's AR Mesh Manager or AR Point Cloud Manager component to visualize the mesh. Magic Leap specific settings, such as MeshingQuerySettings, can be configured via the MagicLeapMeshingFeature class.

Migrating from ML1

This section includes useful information about API changes when migrating Magic Leap 1 applications to Magic Leap 2.

Migrating to OpenXR

In order for an existing Magic Leap 2 Unity application to continue working under OpenXR, here are the minimum steps required:

Mixed Reality Template

The Unity Mixed Reality Template allows developers to start their projects configured for multi-platform mixed reality development. This guide will walk you through updating the Mixed Reality Template project to work with the Magic Leap 2's Unity OpenXR SDK.

ML Spaces Overview

The MLSpace API allows developers to manage Spaces inside their application. This includes functionality such as querying a list of spaces, requesting localization into a specific Space and importing/exporting on device Spaces.

MLCamera

The Magic Leap 2 MLCamera API allows developers to capture real and virtual content inside their applications. While the Magic Leap 2 has only one camera for capturing content, two separate streams can be access from the camera at the same time. This allows you to create applications that can stream the user's point of view, while using the camera to perform computer vision tasks.

MLCamera Examples

This section includes a simple camera example. A detailed explanation of each function can be found in the Camera Overview guide.

MLCamera Overview

The Magic Leap 2 MLCamera API allows developers to capture real and virtual content inside their applications.

MLSpace Examples

These scripts demonstrate various functionalities of the MLSpace API, which is used for managing spaces in a mixed reality environment. The scripts are broken down into specific functionalities: requesting permissions, retrieving available spaces, localizing into a space, exporting and saving spaces, and importing previously saved spaces. Each script serves as an isolated example of a particular functionality, making it easier to understand and implement these functions in your own projects. They are designed to be used with the Unity game engine and the Magic Leap platform. Note that they should be used in a real device environment for proper functioning.

Object Alignment

Object Alignment is a sample application that demonstrates how to attach large scale 3D content, such as digital twin meshes, to a spatial localization map such that the 3D content remains stuck to the world as the user moves around a large space.

Overview

The transition to OpenXR involves the phasing out of MLSDK in favor of OpenXR extensions. To align with this change, Magic Leap’s Unity SDK is shifting from Unity's platform specific XR Plugin (ie: com.unity.xr.magicleap) to Unity's OpenXR Plugin (com.unity.xr.openxr). This shift is accompanied by the addition of new OpenXR Features and API for accessing the functions previously defined by MLSDK C-APIs. This document will outline the rationale behind the move to OpenXR, detail the steps involved in the migration process, and provide insights into the changes and enhancements introduced by this transition.

Photon Fusion

Guide on using the ML2 Photon Fusion example project

Plane Classification

This example uses the OpenXR Unity API. For a previous version using the Unity MLSDK, see this page.

Plane Detection

An overview of the planes demo scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Planes Overview

Magic Leap 2 tries to understand its environment using feature points and planes.

Planes Query

Note: This example uses the OpenXR version of the Magic Leap 2 Unity SDK. For a previous version using the Unity MLSDK, see here.

Platform Detection

This section includes details on detecting if an application is running on a Magic Leap 2 and if a developer is targeting Magic Leap in Unity's XR Manager.

Platform Detection

This section includes details on detecting if an application is running on a Magic Leap 2 and if a developer is targeting Magic Leap in Unity's XR Manager.

Power Manager Example

This example demonstrates how to manage power states and properties on a device using the Magic Leap platform's Power Manager API. It includes initialization and setup of available power states and properties, reading current power state and properties, and setting a new power state. The code also handles different events that could occur during these operations, such as changes in power state or properties, and potential errors. The detailed logging provides real-time insight into the power management process.

Power Manager Overview

Power Manager provides a set of power management APIs that allow applications to receive callbacks when the power state changes, APIs to get device components power state and properties, and to set the controller’s power states.

Query Planes

Learn how to query planes Magic Leap that were detected by the Magic Leap.

Quick Start

This section covers how to use the Magic Leap 2 Controller Interaction Profile with Input System. For more information about obtaining OpenXR Input see Unity's OpenXR Input Documentation.

Quick Start

This section includes information on how to get started using Hand Tracking via Unity's XR Hands Package and the OpenXR Hand Interaction Profile. See the Unity Manual for more information about the XRHands Package and OpenXR Input.

Quick Start

Before adding the sample scripts to your scene, make sure to complete the following:

Render Pipeline Settings

This section assumes you created a new project using the URP template. The URP template project includes a collection of various URP assets, each pre-configured with different settings to represent different levels of quality. However, for Android apps running on our platform, the default configuration does not allow for a smooth 60 FPS experience in even the simplest scene. Follow these steps to configure the URP settings in your project to improve performance.

Render Pipeline Settings

This section assumes you created a new project using the URP template. The URP template project includes a collection of various URP assets, each pre-configured with different settings to represent different levels of quality. However, for Android apps running on our platform, the default configuration does not allow for a smooth 60 FPS experience in even the simplest scene. Follow these steps to configure the URP settings in your project to improve performance.

Rendering Extensions Overview

This section includes information about the Magic Leap 2 OpenXR Rendering Extensions Feature that will make your content appear more robust.

Runtime Configuration

This section provides details on how developers can create and register voice commands dynamically at runtime. This feature can be helpful when loading content dynamically.

Runtime Voice Intents Example

This section provides details on how developers can create voice commands at runtime. This feature can be helpful when loading content dynamically.

SDK Example Scenes

The Magic Leap 2 Unity Example Project showcases the Magic Leap's Unity SDK features. This section includes walkthroughs of each example and can be used as a reference point for development or troubleshooting.

Segmented Dimmer

An overview of the Segmented Dimmer example scene which showcases the segmented dimming range.

Segmented Dimming

Learn how to dim sections of the display to add contrast to certain objects.

Simple Example

This section includes code examples for developers to reference when implementing voice input in their applications.

Simple Grab Interaction

This document provides step-by-step instructions on how to create a cube that can be selected, grabbed and manipulated using Unity's XR Interaction Toolkit and the sample scene created in the Building a Simple App guide.

Simple Meshing Setup

In this tutorial, you'll learn how to set up the Spatial Mapping component with Magic Leap 2 in Unity. By the end of this guide, you'll have a scene capable of meshing the world around you, providing a foundation for immersive mixed reality experiences. The Spatial Mapping in Magic Leap 2 is similar to AR Foundation's Spatial Mapping component.

Soundfield Components

Detailed descriptions and screenshots of all available components of Soundfield Audio

Spatial Anchors

Learn how to link objects to Spatial Anchors and use them to create persistent content.

Spatial Anchors API

Learn the core API calls required to implement Magic Leap 2's Spatial Anchors API.

Spatial Anchors Examples

Contains code that can be used as a reference or demo Magic Leap 2's Spatial Anchors functionality.

Start and Stop Application Simulator

This section walks through the options you have for starting a session in Application Simulator that you can use to run your app. You can use ML C API or Unity apps.

Start/Stop Input

This section provides details on how developers can start and stop tracking voice intents inside their applications.

Troubleshooting

This section reviews different steps you can take to troubleshoot problems you may encounter when using Application Simulator. Topics covered include:

Unity Debugging via Visual Studio

This guide only covers Unity C# script debugging. For C/C++ debugging, i.e. debugging custom or third party libraries, see Unity Native Debugging via Android Studio.

Unity Overview

This section includes information about developing Unity applications for Magic Leap 2.

Unity Platform Defines

Unity does not contain a specific Platform Defines for Magic Leap 2. Instead, developers are required to create and edit custom defines symbols if they wish to use them when developing their applications. This topic describes how to create a custom directive to identify code you wish to include or exclude from your application. For example, you can choose code that will only be compiled when deploying to the Magic Leap 2.

Unity Resources

This section provides various samples, tools, and external libraries that you can reference or integrate into your Magic Leap 2 Unity projects.

Unity Sensor Input

Sensors are devices that measure environmental characteristics of the device that the content is running on, such as light, pressure, temperature, orientation, and motion. Unity’s Input System allows you to access sensors on Android devices using the standard Android Sensor API. In this guide, we will show you how to enable, disable, and read data from sensors on Android using the Input System.

Unity Sensor Input

Sensors are devices that measure environmental characteristics of the device that the content is running on, such as light, pressure, temperature, orientation, and motion. Unity’s Input System allows you to access sensors on Android devices using the standard Android Sensor API. In this guide, we will show you how to enable, disable, and read data from sensors on Android using the Input System.

Visualize Camera Output

This section includes details on rendering the Magic Leap's camera output on a Raw Image UI Component. When receiving camera output developers can query the format using the MLCamera.CameraOutput.Format property.

Voice Input System Settings

The Voice Intent API will only register voice commands if Voice Input is enabled inside the Magic Leap 2's System Settings (Settings > Magic Leap Inputs > Voice). This section demonstrates how to check if a user has enabled Voice Input.

Voice Intents

An overview of the Voice Intents scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

Voice Intents Overview

Magic Leap recommends using the Voice Intent Development Toolkit (VIDTK) to create and deploy custom voice commands. The toolkit provides validation and guidance within the toolkit UI that are not available in the Unity Editor. For more information, see Voice Commands.

Voice Slots

A Slot is a placeholder string for a set of potential values. The utterance will use one of the values and the developer can have different logic based on which value was spoken. To indicate use of a slot, put the slot name within { } for the command.

WebRTC

An overview of the WebRTC scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

WebView

An overview of the WebView scene included in the Magic Leap 2 Examples Project, which uses Unity's XR Interaction Toolkit.

XR Hand Interaction Demo

This guide will demonstrate how to configure the Unity XRI Hands Demo Scene to work with the Magic Leap 2.

XR Origin & ML Rig

This section provides information on how to create a Player Rig that is compatible with Magic Leap 2 and is driven by the user's head and controller movement controller. This can be done by either: