Contains a Unity 5 project featuring two demo scenes for Azure App Services (previously Mobile Services).
This project contains git submodule dependencies so use:
git clone --recursive https://github.com/Unity3dAzure/AppServicesDemo.git
Or if you've already done a git clone then use:
git submodule update --init --recursive
This demo uses Facebook identity to save user's highscore or inventory items:
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.
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!" });
});
}
}
X-HTTP-Method-Override
header. Here's the quick fix for App Services running node backend:
npm install method-override --save
var methodOverride = require('method-override');
// after the line "var app = express();" add
app.use(methodOverride('X-HTTP-Method-Override'));
This will enable PATCH requests to be sent on Android.
Refer to the download instructions above to install these submodules.
Questions or tweet #Azure #GameDev @deadlyfingers