Skip to main content
Version: 21 Aug 2024

MLAutoAPISingleton

NameSpace: MagicLeap

MLAutoAPISingleton class contains a template for singleton APIs More...

Inherits from:
MLLazySingleton< T >

Detailed Description

public template <T > class MLAutoAPISingleton : MLLazySingleton< T > 

Template Parameters:

  • T The type of the class to create a singleton for.

Public Fields

IsStarted

Indicates if the API has started successfully.


public static bool IsStarted { get; set; }


Protected Methods

Initialize

This is the only way to initialize this class.

protected virtual sealed override void Initialize()

Reimplements: Initialize


OnApplicationFocus

Callback sent to all MagicLeap APIs on application focus event.

protected virtual void OnApplicationFocus(
bool hasFocus
)

Parameters

TypeNameDescription
boolhasFocusTrue if the application has focus, else False.

OnApplicationPause

Callback sent to all MagicLeap APIs on application pause.

protected virtual void OnApplicationPause(
bool pauseStatus
)

Parameters

TypeNameDescription
boolpauseStatusTrue if the application is paused, else False.

Reimplemented by: OnApplicationPause, OnApplicationPause, OnApplicationPause, OnApplicationPause, OnApplicationPause, OnApplicationPause, OnApplicationPause


OnDeviceActive

Callback sent to all MagicLeap APIs when device enters active mode.

protected virtual void OnDeviceActive()

OnDeviceReality

Callback sent to all MagicLeap APIs when device enters reality mode.

protected virtual void OnDeviceReality()

OnDeviceStandby

Callback sent to all MagicLeap APIs when device enters standby mode.

protected virtual void OnDeviceStandby()

StartAPI

Do API-specific creation/initialization of ML resources for this API, such as creating trackers, etc. Called automatically the first time Instance is accessed. Error checking on the return value is performed in the base class.

protected virtual abstract MLResult.Code StartAPI()

Reimplemented by: StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI, StartAPI


StopAPI

API-specific cleanup. Will be called whenever MLDevice is destroyed (at the latest, when the application is shutting down). Error checking on the return value is performed in the base class.

protected virtual abstract MLResult.Code StopAPI()

Reimplemented by: StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI, StopAPI


Update

Update function that will run once per Unity frame.

protected virtual void Update()

Reimplemented by: Update, Update, Update


Protected Attributes

APILock

Lock used to keep api calls synchronous.


protected readonly object APILock = new object();


DllNotFoundError


protected readonly string DllNotFoundError = $"Failed to start {typeof(T).Name} API. This API is only available on device or when running inside the Unity editor with Magic Leap App Simulator enabled.";


Handle

The native handle ID for this API instance. Will be invalid until the API is started.


protected ulong Handle = Native.MagicLeapNativeBindings.InvalidHandle;