Migrating from ML1
This article provides an overview on the changes that were made to the Magic Leap SDK and how to access Magic Leap 1 equivalent features on the Magic Leap 2.
Both Magic Leap 1 and Magic Leap 2 define these APIs under the UnityEngine.XR.MagicLeap
namespace.
API Transition Table
Topic | Magic Leap 1 | Magic Leap 2 |
---|---|---|
State | MLHeadTracking.GetState(out State state) | MLHeadTracking.TryGetStateEx(headDevice, out MLHeadTracking.State state); |
Map Events | Delegates were exposed but didn't work | MLHeadTracking.TryGetMapEvents(headDevice, out MLHeadTracking.MapEvents mapEvents); |
info
Head tracking state provides information like tracking mode, confidence and reason for tracking errors.
Overview
using UnityEngine.XR.MagicLeap;
using InputDevice = UnityEngine.XR.InputDevice;
using static UnityEngine.XR.MagicLeap.InputSubsystem.Extensions;
private InputDevice headDevice;
...
// Initialize headDevice in Start() or Update()
headDevice = InputSubsystem.Utils.FindMagicLeapDevice(InputDeviceCharacteristics.HeadMounted | InputDeviceCharacteristics.TrackedDevice);
// Access the head tracking state
MLHeadTracking.TryGetStateEx(headDevice, out MLHeadTracking.StateEx state);
// Access the head tracking map events
MLHeadTracking.TryGetMapEvents(headDevice, out MLHeadTracking.MapEvents mapEvents);
See also
MLHeadTracking.TryGetMapEvents(headDevice, out MLHeadTracking.MapEvents mapEvents);
- API to retrieve the Head Tracking Map Events.
MLHeadTracking.TryGetStateEx(headDevice, out MLHeadTracking.State state);
- API to retrieve the Head Tracking State Events.
- Tracked Pose Driver
- An easy way to access the HMD's positional and rotational input.