Skip to main content
Version: 20 Mar 2024

MagicLeapNativeBindings

NameSpace: Native

Defines C# API interface to C-API layer.

Inherited by:
OpenXR.PointCloud.MagicLeapOpenXRPointCloudNativeBindings,
UnityEngine.XR.MagicLeap.InputSubsystem.Extensions.Controller.NativeBindings,
UnityEngine.XR.MagicLeap.MagicLeapXrProviderNativeBindings,
UnityEngine.XR.MagicLeap.MLAnchors.NativeBindings,
UnityEngine.XR.MagicLeap.MLAudioOutput.NativeBindings,
UnityEngine.XR.MagicLeap.MLAudioPlayback.NativeBindings,
UnityEngine.XR.MagicLeap.MLCameraBase.NativeBindings,
UnityEngine.XR.MagicLeap.MLEyeCamera.NativeBindings,
UnityEngine.XR.MagicLeap.MLGazeRecognition.NativeBindings,
UnityEngine.XR.MagicLeap.MLMarkerTracker.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.DataSource.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.ParserCEA608.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.Player.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.Player.Track.DRM.NativeBindings,
UnityEngine.XR.MagicLeap.MLMedia.Player.Track.NativeBindings,
UnityEngine.XR.MagicLeap.MLMediaRecorder.NativeBindings,
UnityEngine.XR.MagicLeap.MLPowerManager.NativeBindings,
UnityEngine.XR.MagicLeap.MLSpace.NativeBindings,
UnityEngine.XR.MagicLeap.MLTime.NativeBindings,
UnityEngine.XR.MagicLeap.MLVoice.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.AppDefinedAudioSource.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.AppDefinedVideoSource.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.AudioSink.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.DataChannel.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.PeerConnection.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.Source.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.VideoSink.Frame.NativeBindings,
UnityEngine.XR.MagicLeap.MLWebRTC.VideoSink.NativeBindings,
UnityEngine.XR.MagicLeap.MLWorldCamera.NativeBindings,
UnityEngine.XR.MagicLeap.PlanesSubsystem.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapFacialExpressionFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapLocalizationMapFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapMarkerUnderstandingFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapSpatialAnchorsFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapSpatialAnchorsStorageFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapSystemNotificationsFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapUserCalibrationFeature.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MagicLeapXrMeshingNativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MLEyeTracking.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MLHeadTracking.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MLInput.NativeBindings,
UnityEngine.XR.OpenXR.Features.MagicLeapSupport.MLXrPlaneSubsystem.NativeBindings

Public Methods

string MLGetResultString

Returns an ASCII string for MLResultGlobal codes.

public static string MLGetResultString(
MLResult.Code result
)

Parameters

TypeNameDescription
MLResult.CoderesultThe input MLResult enum from ML API methods.

Returns: An ASCII string containing readable version of result code.


bool MLHandleIsValid

Checks if 64 bit handle is valid.

public static bool MLHandleIsValid(
ulong handle
)

Parameters

TypeNameDescription
ulonghandleThe handle to check.

Returns: true , if handle is valid, false if invalid.


IntPtr MLInputGetResultString

Returns a pointer to an ASCII string representation for each result code. This call can return a pointer to the string for any of the MLInput related MLResult codes. Developers should use MLResult.CodeToString(MLResult.Code).

public IntPtr MLInputGetResultString(
MLResult.Code result
)

Parameters

TypeNameDescription
MLResult.CoderesultMLResult type to be converted to string.

Returns: Returns a pointer to an ASCII string containing readable version of the result code.


MLResult.Code MLPerceptionGetPredictedSnapshot

Pulls in the state of all persistent transforms and all enabled trackers extrapolated to the provided timestamp. This timestamp typically comes from out_frame_info.predicted_display_time out parameter from the MLGraphicsBeginFrameEx function. Returns a MLSnapshot with this latest state. This snap should be used for the duration of the frame being constructed and then released with a call to MLPerceptionReleaseSnapshot().

public MLResult.Code MLPerceptionGetPredictedSnapshot(
ulong timestamp,
ref IntPtr out_snapshot
)

Parameters

TypeNameDescription
ulongtimestampTimestamp representing the time for which to predict poses.
ref IntPtrout_snapshotPointer to a pointer containing an MLSnapshot on success.

Returns: MLResult.Result will be MLResult.Code.Ok if operation was successful. MLResult.Result will be MLResult.Code.InvalidTimestamp if Timestamp is either more than 100ms in the future or too old for cached state. MLResult.Result will be MLResult.Code.InvalidParam if Output parameter was not valid (null). MLResult.Result will be MLResult.Code.PerceptionSystemNotStartede if Perception System has not been started.


MLResult.Code MLPerceptionGetSnapshot

Pull in the latest state of all persistent transforms and all enabled trackers extrapolated to the next frame time. Returns an MLSnapshot with this latest state. This snap should be used for the duration of the frame being constructed and then released with a call to MLPerceptionReleaseSnapshot().

public MLResult.Code MLPerceptionGetSnapshot(
ref IntPtr snapshot
)

Parameters

TypeNameDescription
ref IntPtrsnapshotPointer to a pointer containing an MLSnapshot on success.

Returns: MLResult.Result will be MLResult.Code.Ok if operation was successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error.


MLResult.Code MLPerceptionReleaseSnapshot

Pull in the latest state of all persistent transforms and all enabled trackers extrapolated to the next frame time. Return an MLSnapshot with this latest state. This snap should be used for the duration of the frame being constructed and then released with a call to MLPerceptionReleaseSnapshot().

public MLResult.Code MLPerceptionReleaseSnapshot(
IntPtr snap
)

Parameters

TypeNameDescription
IntPtrsnapPointer to a pointer containing an MLSnapshot on success.

Returns: MLResult.Result will be MLResult.Code.Ok if a Snapshot was created successfully successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if a Snapshot was not created successfully.


MLResult.Code MLPlatformGetAPILevel

Query the OS for which Platform API Level is supported.

public MLResult.Code MLPlatformGetAPILevel(
ref uint level
)

Parameters

TypeNameDescription
ref uintlevelPointer to an integer that will store the API level.

Returns: MLResult.Result will be MLResult.Code.Ok if operation was successful. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.InvalidParam if level was not valid (null).


MLResult.Code MLSnapshotGetPoseInBase

Get transform between coordinate frame 'base_id' and the coordinate frame `id' as well as any derivatives that have been calculated.

public MLResult.Code MLSnapshotGetPoseInBase(
IntPtr snap,
ref MLCoordinateFrameUID base_id,
ref MLCoordinateFrameUID id,
ref MLPose outPose
)

Parameters

TypeNameDescription
IntPtrsnapA snapshot of tracker state. Can be obtained with MLPerceptionGetSnapshot().
ref MLCoordinateFrameUIDbase_idThe coordinate frame in which to locate 'id'.
ref MLCoordinateFrameUIDidThe coordinate frame which needs to be located in the base_id coordinate frame.
ref MLPoseoutPoseValid pointer to an MLPose. To be filled out with requested pose data.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to obtain transform due to invalid parameter. MLResult.Result will be MLResult.Code.Ok if obtained transform successfully. MLResult.Result will be MLResult.Code.PoseNotFoundk if coordinate Frame is valid, but not found in the current pose snapshot. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed to obtain transform due to internal error.


IntPtr MLSnapshotGetResultString

Returns a pointer to an ASCII string representation for each result code. This call can return a pointer to the string for any of the MLSnapshot related MLResult codes. Developers should use MLResult.CodeToString(MLResult.Code).

public IntPtr MLSnapshotGetResultString(
MLResult.Code result
)

Parameters

TypeNameDescription
MLResult.CoderesultMLResult type to be converted to string.

Returns: Returns a pointer to an ASCII string containing readable version of the result code.


MLResult.Code MLSnapshotGetStaticData

Get the static data pertaining to the snapshot system. Requires API level 30.

public MLResult.Code MLSnapshotGetStaticData(
ref MLSnapshotStaticData outStaticData
)

Parameters

TypeNameDescription
ref MLSnapshotStaticDataoutStaticDataValid pointer to an MLSnapshotStaticData. To be filled out with snapshot static data.

Returns: MLResult.Result will be MLResult.Code.InvalidParam if failed to obtain static data due to invalid parameter. MLResult.Result will be MLResult.Code.Ok if obtained static data successfully. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed to obtain static data due to internal error.


MLResult.Code MLSnapshotGetTransform

Gets the transform between world origin and the coordinate frame `id'.

public MLResult.Code MLSnapshotGetTransform(
IntPtr snap,
ref MLCoordinateFrameUID id,
ref MLTransform outTransform
)

Parameters

TypeNameDescription
IntPtrsnapA snapshot of the tracker state. Can be obtained with MLPerceptionGetSnapshot().
ref MLCoordinateFrameUIDidLook up the transform between the current origin and this coordinate frame id.
ref MLTransformoutTransformValid pointer to an MLTransform. To be filled out with requested transform data.

Returns: MLResult.Result will be MLResult.Code.Ok if the transform was obtained successfully. MLResult.Result will be MLResult.Code.UnspecifiedFailure if failed due to internal error. MLResult.Result will be MLResult.Code.InvalidParam if failed due to an invalid parameter. MLResult.Result will be MLResult.Code.PoseNotFound if the coordinate frame is valid, but not found in the current pose snapshot.


MLResult.Code MLUnitySdkGetMinApiLevel

Returns the minimum API level of the MLSDK used by Unity

public MLResult.Code MLUnitySdkGetMinApiLevel(
out uint minApiLevel
)

Parameters

TypeNameDescription
out uintminApiLevelValue containing the minimum API level.

Returns: MLResult.Code.Ok : Minimum API level was retrieved successfully. MLResult.Code.NotImplemented : The ml_sdk_loader plugin was not compiled with knowledge of the minimum API level.


bool UnityMagicLeap_TryGetPose

Tries to get the pose for the given coordinate frame id.

public bool UnityMagicLeap_TryGetPose(
MLCoordinateFrameUID id,
out UnityEngine.Pose pose
)

Parameters

TypeNameDescription
MLCoordinateFrameUIDidThe coordinate frame id to get the pose of.
out UnityEngine.PoseposeThe object to initialize the found pose with.

Returns: True if a pose was successfully found.


Protected Methods

MagicLeapNativeBindings

Initializes a new instance of the MagicLeapNativeBindings class.

protected MagicLeapNativeBindings()

Public Attributes

InvalidHandle

The 64 bit id for an invalid native handle.


public const ulong InvalidHandle = 0xFFFFFFFFFFFFFFFF;


MLPerceptionClientDll

Perception library name string.


public const string MLPerceptionClientDll = "perception.magicleap";


MLPlatformDll

Platform level library name string.


public const string MLPlatformDll = "platform.magicleap";


MLSdkLoaderDll


public const string MLSdkLoaderDll = "ml_sdk_loader";


UnityMagicLeapDll

Unity's XR provider library in com.unity.xr.magicleap


public const string UnityMagicLeapDll = "UnityMagicLeap";


Protected Attributes

AudioOutputPluginDLL

Internal DLL used to send unity audio buffers to MLAudio api.


protected const string AudioOutputPluginDLL = "MLAudioOutput";


AudioPlayerDLL

MLAudio library name.


protected const string AudioPlayerDLL = "audio.magicleap";


CUtilsDLL

Internal DLL used to get Java VM Pointer.


protected const string CUtilsDLL = "ml_c_utils";


MLCameraDll

The MLCamera library name.


protected const string MLCameraDll = "camera.magicleap";


MLCameraMetadataDll

Internal DLL used by the API.


protected const string MLCameraMetadataDll = "camera_metadata.magicleap";


MLGazeRecognitionDll

Internal DLL used by the API.


protected const string MLGazeRecognitionDll = "perception.magicleap";


MLInputDll

Internal DLL used by the Input API.


protected const string MLInputDll = "input.magicleap";


MLMediaCEA608DLL

Media CC parser library name


protected const string MLMediaCEA608DLL = "media_ccparser.magicleap";


MLMediaCEA708DLL

Media CEA-708 library name


protected const string MLMediaCEA708DLL = "media_cea708parser.magicleap";


MLMediaDRMDll

Internal DLL used by the API.


protected const string MLMediaDRMDll = "media_drm.magicleap";


MLMediaErrorDLL

MLMediaError library name.


protected const string MLMediaErrorDLL = "media_error.magicleap";


MLMediaFormatDll

Internal DLL used by the API.


protected const string MLMediaFormatDll = "media_format.magicleap";


MLMediaPlayerDll

Internal DLL used by the API.


protected const string MLMediaPlayerDll = "media_player.magicleap";


MLMediaRecorderDll

Internal DLL used by the API.


protected const string MLMediaRecorderDll = "media_recorder.magicleap";


MLNativeSurfaceDll

Internal DLL used by the API.


protected const string MLNativeSurfaceDll = "native_surface.magicleap";


MLNotificationsManagerDll

Internal DLL used by the Notifications API.


protected const string MLNotificationsManagerDll = "system_notification_manager.magicleap";


MLPowerManagerDll

Internal DLL used by the API.


protected const string MLPowerManagerDll = "power_manager.magicleap";


MLSpaceDll

Internal DLL used by the Space API.


protected const string MLSpaceDll = "space.magicleap";


MLVoiceDll

Internal DLL used by the API.


protected const string MLVoiceDll = "input.magicleap";


MLWebRTCDLL

Internal DLL used by the API.


protected const string MLWebRTCDLL = "webrtc.magicleap";


MLWebViewDll

Internal DLL used by the API.


protected const string MLWebViewDll = "webview.magicleap";


MLZIPermissionsDll

ZI permissions library name


protected const string MLZIPermissionsDll = "zi.magicleap";


MediaMuxerDll

Internal DLL used by the API.


protected const string MediaMuxerDll = "media_muxer.magicleap";


Public Enums

MLSensoryState

The current state of a given tracker.

EnumeratorValueDescription
InitializingThe tracker is not ready, don't use the data.
ReadyThe tracker's data can be used.