Accelerometer Class

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

This type is partially wrapped into Unity components: CloudSpatialMapLocalizerFrameFilter . Members and instances of this type are not required to be used directly in most situations. Use this type by CloudSpatialMapLocalizerFrameFilter.Accelerometer instead of creating new instances when a few unwrapped API is desired for use.


Accelerometer calls the accelerometer provided by the operating system, and outputs AccelerometerResult .

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 accelerometer multiple times simultaneously, which may cause failure on open or cause precision downgrade.




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.



public virtual bool open()

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



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.



public virtual void close()

Closes. It shall not be used after calling close.



public virtual Optional< AccelerometerResult > getCurrentResult()

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