Skip to main content
Version: 10 Jul 2024

Examples project

An examples project is available to download from ML Hub that demonstrates how to use several of the Magic Leap plugins included in the Magic Leap Unreal sdk.

Prerequisites

  • To build and run the Unreal examples project to run natively on MagicLeap 2, you will need to create a local build of the Magic Leap fork of Unreal Engine 5.4 with the Magic Leap plugin sdk. See this guide for instructions for building Unreal Engine for native development on Magic Leap 2- Getting Started

Most of the example levels will also work with Magic Leap remote rendering. Note that while you can use official builds of Unreal Engine 5.4 from the Epic Game Launcher for development with MagicLeap remote rendering, you will still need to build the plugin sdk with your project in order for the samples to work. See this guide for setup instructions using remote rendering- Remote Rendering with Unreal Engine 5

Building the project

You can download the examples project using the ML Hub package manager. Download the version of the examples project that corresponds to the version of the Unreal Plugin sdk that you are using. (eg- if you are using plugin sdk v1.5.0, you will want to use v1.5.0 of the example project)

The ML Hub package manager will download the project files to a directory in your MagicLeap folder. If you prefer, you can copy the project files to another location before building the project. Select Open Folder from the details panel in the ML Hub package manager to open the project folder if you want to copy it.

Launch the UE5 editor and click Browse when the Project Browser window appears. Open the Example.uproject file in the example project root directory.

A prompt will appear saying that the project was made with a different version of Unreal Engine. This is expected. Click 'Open a copy'. The project folder will be duplicated in the same directory from where it was located and it will load in the UE5 editor. Note, if you open the project from where it was downloaded by ML Hub, and choose to copy it, the copy will not be removed if you later delete the package using the ML Hub package manager.

The LightEstimation example relies on baked lighting. If you are using a source build of Unreal Engine, and have not already done so, close the Unreal editor, open UE5.sln in Visual Studio, and build the UnrealLightmass project.

After building UnrealLightmass, reopen the examples project in the Unreal editor. From the Build menu, select "Build Lighting Only".

From the Platforms menu in the editor, select Android -> Android (DXT).

Now, from the Platforms menu, select Android -> Package Project to build an apk that you can deploy to your ML2.

Example Levels

HelloCube

Simple hello cube example that just renders a spinning cube.

Controller

This example demonstrates how to receive input from the Magic Leap 2 controller.

HandInteraction

This example demonstrates how to use the Magic Leap Hand Interaction OpenXR plugin.

LightEstimation

This example illustrates how to use the Magic Leap Light Estimation plugin to generate a cube map of your surroundings and detect the main direction light in your environment.

info

You must build the UnrealLightmass project for the example to work correctly.

MarkerTracking

This example demonstrates how to use the Magic Leap Marker Tracking OpenXR plugin to track ArUco and AprilTag markers, QR codes, and barcodes.

PixelSensor (native only)

This example demonstrates how to configure and access data from the various cameras exposed via the Magic leap Pixel Sensor OpenXR API.

Planes

This example demonstrates how to use the Magic Leap Planes OpenXR plugin to detect and display planar surface areas in your environment.

SpatialAnchors (native only)

This example demonstrates how to use the Magic Leap Spatial Anchors OpenXR plugin to create, publish, query, and delete spatial anchors.

WorldMesh (native only)

This example demonstrates how to user the Magic Leap World Mesh plugin to generate a mesh representation of your surroundings.