An update to Azure Services for Unity library

During the past few months I’ve pushed some updates to my Azure Services for Unity library. The goal of this library remained the same: use Azure App Service Easy Tables and Easy APIs easily from a single codebase without any additional Unity addins, I really want this to be a plugin free experience. Here, I’ll summarise some of the main updates in the library. For an intro to the library and an intro on Easy Tables and Easy APIs, check out my original blog post here. Moreover, check here for how to access Azure Table Storage Service from within a Unity game.

OData client

The library at its initial form was using a custom made OData parser. With some work, I’ve managed to integrate the one used by the official Azure App Service.

iOS fix

There were some issues (kind way to say that it wasn’t working!) with iOS, basically because iOS uses AOT compilation. In this way, Reflection.Emit from the OData client did not work on iOS. This was used to generate the Expression Tree from the LINQ query. I ended up using some code from Matt Warren that does not use Reflection.Emit (thanks Matt!).

Total Count

The OData query was not parsing the total row count correctly, so I provided a fix. Remember that Easy Tables can fetch up to 50 rows per query, clearly for performance issues. That’s why you definitely need some paging in your Unity game!

Problem with Android insert

This one is really interesting! UnityWebRequest class uses HttpUrlConnection class on Android to do the necessary HTTP calls. This class does not support the PATCH HTTP verb, which Azure Easy Tables needs for row updates. No easy workaround there for the time being, but we can easily resort to use an Easy API for Android clients that want to update Easy Tables rows. Bonus: you can write some node.js along the way!

Here you can see how the Update method is called in the Unity UI

        //Android disallows PATCH so we can't use the EasyTables solution
        //instead, we need an Easy API solution
        if (Application.platform == RuntimePlatform.Android)
        {
            CallUpdateForAndroid();
        }
        else
        {

            EasyTables.Instance.SelectByID<Highscore>(...)
        }

    public void CallUpdateForAndroid()
    {
        EasyAPIs.Instance.CallAPI<Highscore, Highscore>("UpdateHighScore", HttpMethod.Post, response =>
        { ... }

References

Pending issues

The library currently does not work for UWP Builds. Issues occur mainly because some System.Type related methods are missing from the Universal Windows runtime. I’m still researching on how to overcome these. Feel free to do a pull request if you have a solution :)

There have also been some other minor changes to the library, e.g. the removal of the “Experimental” from UnityWebRequest class namespace (yay!) and I still plan to do some more enhancements, such as Azure Storage support. Any ideas? Feel free to ping me.

Last but not least, many thanks to 9 to Friday studio for their reported issues and some debugging help. A couple of fixes would not be possible without their assistance.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s