docs.unity3d.com
  • Manual
  • Scripting API
  • Changelog
  • License
Magic Leap XR Plugin 7.0.0
  • 7.1 2022.3+
  • 6.4 2020.2+
  • 6.3 2020.2+
  • 6.2 2020.2+
  • 6.1 2020.1+
  • 6.0 2020.1+
  • 5.2 2020.1+
  • 5.1 2020.1+
  • 5.0 2020.1+
  • 4.2 2019.4.4f1+
  • 4.1 2019.3.0b9+
  • 4.0 2019.3.0b5+
  • 3.0 2019.2+
  • 2.0 2019.1+
    Show / Hide Table of Contents
    • About Magic Leap XR Support
    • What's new
    • Manual
    • About Magic Leap XR Support

    About Magic Leap XR Support

    Use the Magic Leap XR Support package to enable Magic Leap via Unity's multi-platform XR SDK. This package implements the following XR Subsystems:

    • Display
    • Input
    • Meshing

    This version of Magic Leap XR Support supports the meshing functionality provided by the Magic Leap 2:

    • Generate meshes of the environment
    • Generate point clouds of the environment

    Installing Magic Leap XR Support

    This topic only discusses how to install the individual Magic Leap XR Support package. Follow these instructions when you need to install or reinstall this package on its own. This process does not install the Magic Leap SDK package or the other tools provided by Magic Leap. To set up the full Magic Leap 2 development environment, refer to the Magic Leap 2 Unity Getting Started Guide on the Magic Leap Developer Portal.

    To install this package:

    1. Open the project that you plan to use (in Unity 2022.2+).
    2. Click the following link to begin the installation: com.unity.xr.magicleap.

      The Unity Package Manager window opens with the package name entered in the Add package by name dialog.

    3. (Optional) Enter the full version number, such as 7.0.0-exp.3, to install. If left blank, Unity chooses the "best" version -- typically the latest, release version for the current Unity Editor. See the Changelog for a list of versions available at the time this documentation page was published.

    4. Click Add.
    Note

    Magic Leap 2 runs on the Android operating system. If you don't already have the Unity Android platform module installed, then you must use the Unity Hub to install it for the current Unity Editor. See Add modules in the Unity Hub documentation for instructions.

    Additional resources Description
    Adding a registry package by name More detailed instructions for adding a package by name.
    The Package Manager tutorial An overview of installing and managing packages in Unity.
    Package Manager Detailed documentation about the Package Manager in the Unity Manual.
    Magic Leap Unity Development Unity documentation maintained by the Magic Leap Developer Portal.

    Using Magic Leap XR Support

    The Magic Leap XR Support implements the native endpoints required for meshing using Unity's multi-platform XR API.

    Inclusion of the Magic Leap XR Support will result in the inclusion of a C# component, runtime libraries, and plugin metadata.

    Spatial Mapper

    This package includes the MLSpatialMapper component:

    The spatial mapper generates Mesh objects from data collected from the Magic Leap 2's depth sensor. Each mesh is a relatively small area of the environment. A separate GameObject is created for each generated mesh.

    Field Description
    Mesh Prefab This is the prefab that will be instantiated for each generated mesh. The prefab should at least have a MeshFilter on it. To visualize the meshes, add a MeshRenderer. If a MeshCollider is present, then a physics collider will be generated as well. This happens on a background thread, so it will not stall the main thread.
    Compute Normals If true, will request that the device also generate a normal for each vertex. If false, normals will be calculated from the triangle data.
    Mesh Parent The parent transform for the generated meshes. By default, the MLSpatialMapper will select its own parent, so that the generated meshes will be siblings of the MLSpatialMapper's GameObject.
    Type Whether to generate triangle meshes or a point cloud. If you select point cloud, then the resulting Mesh will have MeshTopology.Points.
    Level of Detail (Deprecated) The detail of the generated meshes. Lower levels of detail will result in simplified meshes, and will reduce CPU and GPU load, but will be less accurate. Higher LOD levels will be more accurate, but require more CPU and GPU resources. This property is deprecated, and has been replaced by density.
    Mesh Density Controls the size and spacing of triangles in meshes. The scale goes from low density at 0 (big triangles) to high density at 1 (small triangles). Higher density meshes require more CPU and GPU resources.
    Mesh Queue Size The number of concurrent meshes to generate. Each frame, the MLSpatialMapper will add meshes to a generation queue as necessary. Larger values will lead to heavier CPU usage, but will generate meshes faster.
    Fill Hole Length Perimeter (in meters) of holes you wish to have filled.
    Polling Rate How often to check for updates, in seconds. More frequent updates will increase CPU usage.
    Batch Size Maximum number of meshes to update per batch. Larger values are more efficient, but have higher latency.
    Planarize If true, the system will planarize the returned mesh (planar regions will be smoothed out).
    Disconnected Component Area Any component that is disconnected from the main mesh and which has an area (in meters squared) less than this size will be removed.
    Request Vertex Confidence If true, the system will compute the confidence values for each vertex, ranging from 0 to 1.
    Remove Mesh Skirt If true, the mesh skirt (overlapping area between two meshes) will be removed.

    Bounds

    Meshes are only generated inside a specific region, relative to the Magic Leap 2's starting position. The MLSpatialMapper's transform is used to define this region. The transform's localPosition, localRotation, and localScale are used for this calculation.

    A green, transparent box is drawn in Unity's Scene View to indicate the area in which meshing will occur:

    Spaces

    Meshes are generated in "device space", also know as "session relative space". When the Magic Leap 2 boots up, its initial position is (0, 0, 0). All meshing data is relative to this initial location.

    The Camera's GameObject should have an identity transform to begin with.

    If you wish to have the device start at a different location within the Unity scene, we recommend you use a parent GameObject to provide position, rotation, and scale (the Magic Leap Root in this image):

    Gesture

    Subsystem implementation to provide for recognition and tracking of gestures provided from the appropriate device. This subsystem relies on the com.unity.xr.interactionsubsystem package for it's core implementation (see that package's documentation for further details/types).

    The MagicLeapGestureSubsystem component manages a low-level interface for polling for Magic Leap gesture changes. If this component is added to a scene, it is possible to poll for any gesture events each frame. The following gestures and gesture data are provided:

    • MagicLeapKeyPoseGestureEvent - Event that fires when a key pose gesture changes. See the Magic Leap documentation for further documentation on key poses.
      • id - Unique GestureId that identifies this gesture.
      • state - GestureState that indicates the state of this gesture (Started, Updated, Completed, Canceled or Discrete).
      • keyPose - MagicLeapKeyPose indicating type of key pose that has been detected. Valid key poses are Finger, Fist, Pinch, Thumb, LShape, OpenHand, Ok, CShape, NoPose, NoHand are all valid key poses.
      • hand - MagicLeapHand indicating the hand source for this gesture (Left or Right);
    • MagicLeapTouchpadGestureEvent - Event that fires when a touchpad gesture changes. See the Magic Leap documentation for further documentation on the touchpad.
      • id - Unique GestureId that identifies this gesture.
      • state - GestureState that indicates the state of this gesture (Started, Updated, Completed, Canceled or Discrete).
      • controllerId - The controller id associated with this gesture.
      • angle - Angle from the center of the touchpad to the finger.
      • direction - MagicLeapTouchpadGestureDirection indicating the direction of this gesture (None, Up, Down, Left, Right, Clockwise, CounterClockwise).
      • positionAndForce - Gesture position (x,y) and force (z). Position is in the [-1.0,1.0] range and force is in the [0.0,1.0] range.
      • radius - For radial gestures, this is the radius of the gesture. The touchpad is defined as having extents of [-1.0,1.0] so this radius has a range of [0.0,2.0].
      • speed - Speed of gesture. Note that this takes on different meanings depending on the gesture type being performed:
      • type - MagicLeapInputControllerTouchpadGestureType indicating the type of this gesture (None, Tap, ForceTapDown, ForceTapUp, ForceDwell, SecondForceDown, RadialScroll, Swipe).

    Additionally, the MagicLeapGestures component can be used to provide a simpler polling mechanism for a simpler, event-based interface for listening to gestures. This component provides a number of events that be hooked into to detect gesture events when they occur:

    • onKeyPoseGestureChanged - Occurs whenever a key pose gesture changes state.
    • onTouchpadGestureChanged - Occurs whenever a touchpad gesture changes state.
    • onActivate - Occurs whenever the cross-platform activate gesture occurs. See the com.unity.xr.interactionsubsystems package documentation for more details.

    Also see the relevant Magic Leap documentation about gestures for supported device information.

    Technical details

    Requirements

    This version of Magic Leap XR Support is compatible with the following versions of the Unity Editor:

    • Unity 2022.2+

    Known limitations

    No known issues.

    Package contents

    This version of Magic Leap XR Support includes:

    • A shared library which provides implementation of the XR Subsystems listed above
    • A plugin metadata file

    Did you find this page useful? Please give it a rating:

  • Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • About Magic Leap XR Support
    • Installing Magic Leap XR Support
    • Using Magic Leap XR Support
      • Spatial Mapper
      • Spaces
      • Gesture
    • Technical details
      • Requirements
      • Known limitations
      • Package contents
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023
    By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
    Company Logo

    Privacy Preference Center

    Your Opt Out Preference Signal is Honored
    • Your Privacy

    • Functional Cookies

    • Performance Cookies

    • Targeting Cookies

    • Strictly Necessary Cookies

    Your Privacy

    When you visit any website, it may store or retrieve information on your browser, mostly in the form of cookies. This information might be about you, your preferences or your device and is mostly used to make the site work as you expect it to. The information does not usually directly identify you, but it can give you a more personalized web experience. Because we respect your right to privacy, you can choose not to allow some types of cookies. Click on the different category headings to find out more and change our default settings. However, blocking some types of cookies may impact your experience of the site and the services we are able to offer.
    More information

    Functional Cookies

    Active

    These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages. If you do not allow these cookies then some or all of these services may not function properly.

    Performance Cookies

    Active

    These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site. All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.

    Targeting Cookies

    Active

    These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites. They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising. Some 3rd party video providers do not allow video views without targeting cookies. If you are experiencing difficulty viewing a video, you will need to set your cookie preferences for targeting to yes if you wish to view videos from these providers. Unity does not control this.

    Strictly Necessary Cookies

    Always Active

    These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.

    Cookie List

    Consent Leg.Interest
    label
    label
    label
      label
      Powered by Onetrust