ASUS Aura SDK v3.1 Developer's Guide
All Classes Namespaces Functions Variables Enumerations Enumerator Properties Modules Pages
AURA Plugin for Unity

Before installing Aura SDK Plugin for Unity, the Lighting Service (which includes Aura SDK) and Aura Layer Manager should be installed first. See Installation for details.

  1. Unzip the Aura Plugin ZIP file and get AuraPlugin.unitypackage package file.
  2. In Unity, select Assets -> Import Package -> Custome Package..., and locate AuraPlugin.unitypackage that you got in previous step.

  1. Then the Import Unity Package window pops up. There is a complete demo project in this package. You can import all of them if you want. In this example, we want to create a new project from scratch, so just keep Plugin (and the DLL's in it) checked and uncheck everything else.

    Then click Import to import the plugin.

  1. Create a behaviour and associate it with an object in the scene. In this example, we create Cube object, and then a CubeBehaviour that associates with it.

  1. Now it's time to edit CubeBehavior.cs for AURA features. First of all, you need to import AURA namespace by using AsusAuraWrapper:
    Definition: Class1.cs:27
  2. We need a data member to handle AsusAuraService object, and another data for breathing effect:
    public class CubeBehaviour : MonoBehaviour
    {
    private AsusAuraService auraService = null;
    private float auraBreatheTime = 0;
    //...
  3. In Start(), we can initialize AURA by creating the AsusAuraService object. A try/catch block is used here in case there is something bad happened while initialization. Note that AsusAuraService.EnterSDKMode() must be called right after the AsusAuraService object has been created.
    // Start is called before the first frame update
    void Start()
    {
    try
    {
    auraService = new AsusAuraService();
    auraService.EnterSDKMode();
    auraService.SetAllLightsToColor(0, 0, 0, 255); // start from BLACK!
    }
    catch(System.Exception)
    {
    auraService = null;
    }
    }
  4. In Update(), we can update color of LED's on AURA devices. In this example, the delta-time data is used to create some sort of "Breathing" effect. Note that we don't have to call something like IAuraSdk::Apply(); it is handled internally in the plugin.
    // Update is called once per frame
    void Update()
    {
    if (auraService != null)
    {
    auraBreatheTime += Time.deltaTime * 1000;
    auraBreatheTime %= 2000;
    uint blue_value;
    if (auraBreatheTime < 1000.0f)
    {
    blue_value = (uint)(255 * (auraBreatheTime / 1000));
    }
    else
    {
    blue_value = (uint)(255 * ((2000 - auraBreatheTime) / 1000));
    }
    auraService.SetAllLightsToColor(0, 0, blue_value, 255);
    }
    }
  5. Before the application exits, AsusAuraService.ExitSDKMode() needs to be called. It can be done in the OnApplicationQuit() method:
    void OnApplicationQuit()
    {
    if (auraService != null)
    {
    auraService.ExitSDKMode();
    }
    }
  6. It's done. Now we can try to run this application.