Tutorial for Unity



The Unity plugin now has beta support for iOS and OS X devices. You can also run and test your project as you develop from the Unity editor in a computer running OS X 10.11+, but please note that the Unity editor plugin is still in beta, and on some computers you might experience some crashes when running your game from the editor, so make sure you save frequently when you make changes to the scene!

Also, when building for iOS you need to add GemSDK.framework to Embedded Binaries under project settings manually before running the application.

Coordinate system

In GemSDK we use left-handed local coordinate system (fig. above).

GemSDK features:

Start with GemSDK

Our Unity plugin is available by this link.

After importing  plugin to your project in “GemSDK/Scenes” you can find sample scene:


The key script is “GemController.cs” that attached to Gem model:
using UnityEngine;
using UnityEngine.UI;
using GemSDK.Unity;

public class GemController : MonoBehaviour
    public Text stateText;
    private IGem gem;

    // Use this for initialization
    void Start()

        //To get gem by number instead of address, on Android the Gem should be paired to Gem SDK Utility app
        gem = GemManager.Instance.GetGem(0);
        //gem = GemManager.Instance.GetGem("FF:FF:FF:FF:FF:FF");

    void FixedUpdate()
        if (gem != null)
            if (Input.GetMouseButton(0))

                //Use instead of CalibrateAzimuth() to calibrate also tilt and elevation

            transform.rotation = gem.Rotation;
            stateText.text = gem.State.ToString();

    void OnApplicationQuit()

    //For Android to unbind Gem Service when application is not in focus
    void OnApplicationPause(bool paused)
        if (Application.platform == RuntimePlatform.Android)
            if (paused)

To connect to the Gem you need to specify its address or number in the list of paired devices. Second option is recommended only for developement. In Start() function you can see this approach. For windows we’re using list of Gems paired in Bluetooth device manager. For Andoird – Gem SDK Utility app(Play Market or apk), it simplifies Gem devices management during developement.

To get full list of paired Gems use this code for Windows:

string[] gemAddresses = WindowsBleManager.GetPairedGems(); 

and for Android

string[] gemAddresses = GemSDKUtilityApp.GetWhiteList(); 

To find out how to scan for gems manually on Android check out the corresponding section below.

[Android]If the Gem wasn’t disconnected manually before unbinding the serivce, the service will keep connection for 10 sec.

Getting data

It’s strongly recommeded according to perfomance to get data from Gems in FixedUpdate() function.

void FixedUpdate()
    if (gem != null) 
        GemState gemState = gem.State;

        Quaternion rotation = gem.Rotation;
        Vector3 acceleration = gem.Acceleration;

        PedometerData pedometer = gem.Pedometer;
        bool tapOccured = gem.CheckTapOccured();

Pedometer and tap handling should be enabled manually:

gem = GemManager.Instance.GetGem(0);


To consider current azimuth(yaw) angle as zero for curtain Gem just use


And to make rotation completely relative to current rotation use


Using multiple gems

You can call easyly use multiple gems (as much as your Android device can handle)

gem1 = GemManager.Instance.getGem(0);
gem2 = GemManager.Instance.getGem(1);

Scanning gems (Advanced)

To your own way of building Gem white list inside your Android app we provide API for scanning Gems around.

Create scanner class instance and specify its callback:

scanner = new GemAndroidScanner();

Then you can start scanning:

scanner.StartScan(15); //Stop scanning automatically in 15 sec 

Scan process can be stopped earlier with:


You can access scanning results this way:

GemInfo[] gems = scanner.Devices;

This list updates when any new scan response has been cought. Not only when scanning has been stopped.


Over-the-Air updating (Advanced)

Currently API is not available. Bur you can update your Gems via Gem SDK Utility for Android mentioned above


To get sample projects check out our Github page