Magnetometer Class

This type is an EasyAR Sense API in C#: Magnetometer . Some descriptions may not apply to Unity environment on this page.

Some parts of the Sense API may have already been wrapped into Unity components, and directly usages may not be necessary.

Description

Magnetometer calls the magnetometer provided by the operating system, and outputs MagnetometerResult .

When it is not needed anymore, call close function to close it. It shall not be used after calling close.

It is not recommended to open the magnetometer multiple times simultaneously, which may cause failure on open or cause precision downgrade.


Methods

isAvailable

C#

public virtual bool isAvailable()

Checks if the component is available. It returns true only on Android or iOS with supported hardware. On other operating systems, it is not supported.

output

C#

public virtual MagnetometerResultSource output()

Output port.

open

C#

public virtual bool open()

Opens the device. Sampling period is defined by implementation. If failed, it will return false.

openWithSamplingPeriod

C#

public virtual bool openWithSamplingPeriod(int samplingPeriodMilliseconds)

Opens the device with a specific sampling period. Sampling period is limited by hardware and may not reach the specified value. If failed, it will return false.

close

C#

public virtual void close()

Closes. It shall not be used after calling close.

getCurrentResult

C#

public virtual Optional< MagnetometerResult > getCurrentResult()

Gets the most recent result. If there is no result, it returns empty.