Contains a Unity 5 project featuring two demo scenes for Azure App Services (previously Mobile Services).
- Highscores demo scene
- Inventory demo scene
- Client-directed login with Facebook
- Insert Highscore
- Update Highscore
- Read list of Highscores using infinite scrolling (hall of fame)
- Query for today's top ten highscores (daily leaderboard)
- Query for username (user's scores)
- Client-directed login with Facebook
- Load User's inventory.
- Save User's inventory. (Inserts if new or Updates existing record)
- Create an Azure Mobile App
- Create 'Highscores' and 'Inventory' table for storing app data using Easy Tables.
- In Unity open scene file(s) inside the Scenes folder:
- HighscoresDemo.unity
- InventoryDemo.unity
- Then select the AppServicesController gameobject in the Unity Hierarchy window and paste your Azure App Service URL into the Editor Inspector field.

This demo uses Facebook identity to save user's highscore or inventory items:
- Create Facebook app
- Fill in the Azure App Services Authentication settings with Facebook App Id & App Secret.
- Paste Facebook access user token into Unity access token field to enable Login button.
- Modify 'Highscores' and 'Inventory' table script (using 'Insert' snippet below) to save
user.id
var table = module.exports = require('azure-mobile-apps').table();
table.insert(function (context) {
if (context.user) {
context.item.userId = context.user.id;
}
return context.execute();
});With Azure App Services you can create custom APIs using Easy APIs.
- Create a 'hello' api (using "get" method) to say hello! (Example Easy API message script below)
- Create a 'GenerateScores' api (using "post" method) to generate 10 random scores. (Example Easy API query script below)
module.exports = {
"get": function (req, res, next) {
res.send(200, { message : "Hello Unity!" });
}
}var util = require('util');
module.exports = {
"post": function (req, res, next) {
var insert = "INSERT INTO Highscores (username,score) VALUES ";
var i = 10;
while (i--) {
var min = 1;
var max = 1000;
var rand = Math.floor(Math.random() * (max - min)) + min;
var values = util.format("('%s',%d),", 'Zumo', rand);
insert = insert + values;
}
insert = insert.slice(0, -1); // remove last ','
var query = {
sql: insert
};
req.azureMobile.data.execute(query).then(function(results){
res.send(200, { message : "Zumo set some highscores!" });
});
}
}- Inventory uses pixel art icons designed by Henrique Lazarini
- AppService for Unity implements UnityRestClient which uses JsonFx to parse JSON data.
- TSTableView is used to display recyclable list of results.
- iOS
- Android
- Windows
Questions or tweet #Azure #GameDev @deadlyfingers