Unity Engine SDK

The AcceleratXR SDK for Unity provides a simple wrapper around the C# SDK in addition to prefabs and basic scripts included to make the process of working with the platform easier.

Installation

There are two methods to import the SDK into your Unity project.

  1. Link teh repository directly via the manifest.json file. [RECOMMENDED]

  2. Clone the repo and link from a local disk path

Linking Directly

  1. Close the project or Unity editor if currently open.

  2. Open the Packages/manifest.json file in your favorite text editor.

  3. Add the following line to the dependencies set.

    {
        "dependencies": {
            "com.acceleratxr.sdk": "https://automation:heRnZ9HPcm8kT9Ek-Czh@gitlab.acceleratxr.com/Core/sdk/sdk_unity.git"
        }
    }
    
  4. Open your project in the Unity editor.

Linking from the Local Disk

  1. Clone the repository to your local machine.

    git clone https://gitlab.acceleratxr.com/Core/sdk/sdk_unity.git
    
  2. Open your project in the Unity editor.

  3. Open the Package Manager (e.g. Windows -> Package Manager).

  4. Click the + button in the top left corner.

  5. Select Add package from disk....

  6. Browse to the folder that you have cloned the SDK and click Open.

Configuration

In order for your game or application to communicate with an AcceleratXR cluster you must first configure the SDK plug-in. This can be accomplished by creating a new Asset of type AXRCoreSDK. Simply go to Assets -> AcceleratXR -> Core SDK. This will create a new ScriptableObject asset in your project. Once created you will see an inspector window with the settings you will need to configure.

The most important setting is BaseUrl. This is the URL to your AcceleratXR cluster that your app will communicate with.

The JWT settings are optional and only needed if you will be using the ClientSDK.LocalLogin() function. The JWT Settings section and LocalLogin function is provided for debugging purposes and is not recommended for production use. For production builds make sure that the JWTPassword field is blank.

In order to make sure that your configuration is properly loaded once you make a build you will need to add it to the Preloaded Assets list. Go to the Player Settings -> Other Settings -> Preloaded Assets. Expand the list and add an entry, then link the asset you created.

### Using the AcceleratXR Demo Environment

You can use the following settings to utilize AcceleratXR’s demo environment.

Global Settings
URL: https://api.demo.goaxr.cloud/v1

JWT Settings
Audience: demo.goaxr.cloud
Issuer: api.demo.goaxr.cloud
Password:

Note that the demo environment has a limited feature set that will result in run-time failures when using certain SDK services.

Updating the SDK

Local Path

If you cloned the repo locally you can update the SDK by performing a git pull on the folder that you have cloned this repository to. You do not need to restart the Unity Editor for changes to take effect.

Accessing the SDK from Code

The instance of the AXRCoreSDK asset can be easily accessed from anywhere in your code.

using axr.sdk;
using UnityEngine;

public class MyBehavior : MonoBehaviour
    void Start()
    {
        AXRCoreSDK SDK = AXRCoreSDK.GetInstance();
        if (SDK != null)
        {
            CoreSDK = SDK.Instance;
            EntityWatchdog = SDK.EntityWatchdog;
            ServiceFactory = SDK.ServiceFactory;
        }
    // ...
    }
}

Multiple User Support

The SDK supports multiple users through the creation of multiple AXRCoreSDK assets. This can be useful when developing a game that supports split-screen multi-player.

For example if you want to support two-player split-screen where each player has their own login to AcceleratXR this can be easily accomplished by creating two asset instances of AXRCoreSDK.

To access these instances use the name of the asset when calling AXRCoreSDK.GetInstance() as shown in the example below.

using axr.sdk;
using UnityEngine;

public class PlayerOneBehavior : MonoBehaviour
    void Start()
    {
        AXRCoreSDK SDK = AXRCoreSDK.GetInstance("PlayerOne");
        if (SDK != null)
        {
            CoreSDK = SDK.Instance;
            EntityWatchdog = SDK.EntityWatchdog;
            ServiceFactory = SDK.ServiceFactory;
        }
    // ...
    }
}