The definitive Azure SDK for Unity3D with local SQLite database support.
Clone or download

README.md

lightbuzz-azure-unity-logo

Azure App Service SDK for Unity3D

The LightBuzz Azure SDK for Unity3D is a framework that allows you to consume remote Azure App services and even store data locally. It's secured using HTTPS. Supports Android, iOS, Windows Standalone, Mac OS, and UWP (including HoloLens).

It's a cross-platform SDK you can actually use in your apps and games without compatibility problems.

lightbuzz-azure-unity

Download

To use the SDK, you can either clone the current repository or download the .unitypackage file from the Releases section.

cloud-download Download the latest stable version »

Documentation

You can read the documentation online on lightbuzz.com/tools/azure-unity/documentation.

Features

Azure App Services

The LightBuzz Azure SDK for Unity consumes Azure App Service APIs. Azure App Services is a service for hosting web applications, REST APIs, and mobile back ends for any platform or device.

HTTPS

The LightBuzz SDK is built with security in mind. The native Microsoft MobileServiceClient does not support HTTPS in Unity. Our team has built the HTTP requests from scratch using the UnityWebRequest class. This way, your data are encrypted and transmitted securely.

HTTP(S) methods

The LightBuzz SDK supports all of the HTTP(S) method requests.

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE

Local Database

Unlike most of the available SDKs, the LightBuzz Azure SDK for Unity fully supports local database storage. This means you can use the Azure App Services to store data into a local SQLite database. You can sync your local data with the remote server, performing pull and push operations. As a result, your customers can use your app/game without an active Internet connection!

The local database is using the official version of SQLite. SQLite is the most popular and lightweight relational database system for desktop and mobile devices. For UWP, we are using SQLitePCL, which is Microsoft's recommendation for Windows Store apps.

Supported Platforms

The LightBuzz Azure SDK for Unity supports the following platforms:

  • Unity Editor
  • Android
  • iOS
  • Windows Desktop (Standalone)
  • MacOS (Standalone)
  • Universal Windows Platform (UWP) + HoloLens

lightbuzz-azure-hololens

Requirements

To use the SDK, Unity 2017 LTS or Unity 2018 is recommended.

Scripting Runtime

The SDK is built with the latest C# features, so you need to use the .NET 4.x Scripting Runtime version.

In Unity 2018, the scripting runtime is set to 4.x by default.

unity-2018-scripting-runtime

In Unity 2017, you need to explicitly select "Experimental (.NET 4.6 Equivalent)".

unity-2017-scripting-runtime

Scripting Backend

The SDK works with the following Scripting Backend options:

Standalone Android iOS UWP
Mono Mono IL2CPP .NET

Apply Build Settings

Using the SDK, you can apply the proper Unity Build Settings automatically. On the Unity menu bar, select LightBuzzApply Build Settings for... and then select the target platform. The SDK will automatically apply the proper build settings for you.

lightbuzz-build-settings

How to use

In the included samples, we have created a simple demo that implements Microsoft's ToDo List example.

We have implemented a generic Data Access Object for you to use, called MobileAppsTableDAO. The MobileAppsTableDAO supports all of the common CRUD operations out-of-the-box. All you need to do is call the proper C# methods.

Using the code is fairly simple:

Initialization

private string mobileAppUri = "https://testtodolightbuzz.azurewebsites.net";
private bool supportLocalDatabase = true;
private MobileServiceClient azureClient;
private AppServiceTableDAO<TodoItem> todoTableDAO;

private async Task Init()
{
    azureClient = new SampleMobileClient(mobileAppUri, supportLocalDatabase);
    await azureClient.InitializeLocalStore();

    todoTableDAO = new AppServiceTableDAO<TodoItem>(azureClient);
}

Get

private async Task Get()
{
    List<TodoItem> list = await todoTableDAO.FindAll();

    foreach (TodoItem item in list)
    {
        Debug.Log("Text: " + item.Text);
    }
}

Insert

private async Task Insert()
{
    TodoItem item = new TodoItem
    {
        Text = "Hello World!"
    };

    await todoTableDAO.Insert(item);
}

Delete

private async Task Delete()
{
    List<TodoItem> list = await todoTableDAO.FindAll();

    TodoItem item = list.LastOrDefault();

    if (item != null)
    {
        await todoTableDAO.Delete(item);
    }
}

Sync local and remote data

In case you are using the local database for offline functionality, here is how to perform the pull and push requests:

private async Task Sync()
{
    await azureClient.Sync();
}

Contributors

The SDK is brought to you by LightBuzz Inc., a New York based company.

If you would like to contribute to the SDK, please make a pull request.

Resources

Contact us

LightBuzz has been developing Mobile and Cloud solutions for Fortune 500 and startup companies since 2012. Get in touch with us to start a project with a reliable and trusted partner.