Skip to content

Commit b428f3e

Browse files
Merge pull request #27 from Unity3dAzure/iss26
Iss26
2 parents fab762e + bdc1ade commit b428f3e

22 files changed

+214
-90
lines changed
Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# Azure Mobile Services for Unity3d
2-
For game developers looking to use Azure Mobile Services or Azure App Services in their Unity3D project.
1+
# Azure App Services for Unity3d
2+
For game developers looking to use Azure App Services (previously Mobile Services) in their Unity project.
33

4-
Also available as a [MobileServices Demo Project](https://github.com/Unity3dAzure/MobileServicesDemo) which will run inside UnityEditor and on iOS, Android and Windows. The demo project has got everything bundled in and does not require any additional assets to work. If you want to integrate with an existing Unity3d project then follow instructions below:
5-
6-
## How to add MobileServices into Unity3d project
4+
## How to setup App Services with a new Unity project
75
1. [Download UnityRestClient](https://github.com/ProjectStratus/UnityRestClient/archive/master.zip)
86
* Copy JsonFx 'plugins' and the UnityRestClient 'Source' into project `Assets` folder
9-
2. [Download MobileServices](https://github.com/Unity3dAzure/MobileServices/archive/master.zip)
10-
* Copy 'MobileServices' into project `Assets` folder.
11-
3. Create an [Azure Mobile Service](https://manage.windowsazure.com) or an [Azure App Service](https://portal.azure.com)
12-
* Create a table for app data.
7+
2. [Download AppServices](https://github.com/Unity3dAzure/AppServices/archive/master.zip)
8+
* Copy 'AppServices' into project `Assets` folder.
9+
3. Create an Azure App Service [Mobile App](https://portal.azure.com)
10+
* Create a Table (using Easy Tables) for app data.
11+
12+
## Unity 5 leaderboard demo
13+
[App Services Demo project](https://github.com/Unity3dAzure/AppServicesDemo) will run inside UnityEditor on Mac or Windows. (The demo project has got everything bundled in and does not require any additional assets to work.)
14+
Read developer guide on [using Azure App Services to create Unity highscores leaderboard](http://www.deadlyfingers.net/azure/azure-app-services-for-unity3d/) for detailed instructions.
1315

1416
## Supported Features
1517
### MobileServiceClient
@@ -49,7 +51,7 @@ using System.Net;
4951
using System.Collections.Generic;
5052
using RestSharp;
5153
using Pathfinding.Serialization.JsonFx;
52-
using Unity3dAzure.MobileServices;
54+
using Unity3dAzure.AppServices;
5355
5456
```
5557

@@ -60,7 +62,7 @@ private MobileServiceTable<TodoItem> _table;
6062

6163
```
6264
void Start () {
63-
_client = new MobileServiceClient(appUrl, appKey); // <- add your app connection strings here.
65+
_client = new MobileServiceClient(appUrl); // <- add your app url here.
6466
_table = _client.GetTable<TodoItem>("TodoItem");
6567
}
6668
```
@@ -84,4 +86,9 @@ private void OnReadItemsCompleted(IRestResponse<List<TodoItem>> response) {
8486
## Dependencies
8587
The REST service implements [UnityRestClient](https://github.com/ProjectStratus/UnityRestClient) which uses [JsonFx](https://bitbucket.org/TowerOfBricks/jsonfx-for-unity3d-git/) to parse JSON data.
8688

89+
## Supports
90+
* iOS
91+
* Android
92+
* Windows
93+
8794
Questions or tweet #Azure #GameDev [@deadlyfingers](https://twitter.com/deadlyfingers)

Assets/MobileServices/authentication/MobileServiceAuthenticationProvider.cs renamed to Assets/AppServices/authentication/MobileServiceAuthenticationProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Unity3dAzure.MobileServices
1+
namespace Unity3dAzure.AppServices
22
{
33
public enum MobileServiceAuthenticationProvider
44
{

Assets/MobileServices/client/IAzureMobileServiceClient.cs renamed to Assets/AppServices/client/IAzureMobileServiceClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System;
44
using RestSharp;
55

6-
namespace Unity3dAzure.MobileServices
6+
namespace Unity3dAzure.AppServices
77
{
88
public interface IAzureMobileServiceClient
99
{

Assets/MobileServices/client/MobileServiceClient.cs renamed to Assets/AppServices/client/MobileServiceClient.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
using RestSharp;
44
using System.Collections.Generic;
55
using System;
6+
using System.Text.RegularExpressions;
7+
8+
69
#if !NETFX_CORE || UNITY_ANDROID
710
using System.Net;
811
using System.Security.Cryptography.X509Certificates;
912
using System.Net.Security;
1013
#endif
1114

12-
namespace Unity3dAzure.MobileServices
15+
namespace Unity3dAzure.AppServices
1316
{
1417
public class MobileServiceClient : RestClient, IAzureMobileServiceClient
1518
{
@@ -22,6 +25,7 @@ public class MobileServiceClient : RestClient, IAzureMobileServiceClient
2225

2326
/// <summary>
2427
/// Creates a new RestClient using Azure Mobile Service's Application Url and App Key
28+
/// NB: Mobile Services should be migrated to use Azure App Service with constructor below.
2529
/// </summary>
2630
public MobileServiceClient(string appUrl, string appKey) : base(appUrl)
2731
{
@@ -31,7 +35,7 @@ public MobileServiceClient(string appUrl, string appKey) : base(appUrl)
3135
// required for running in Windows and Android
3236
#if !NETFX_CORE || UNITY_ANDROID
3337
Debug.Log("ServerCertificateValidation");
34-
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
38+
ServicePointManager.ServerCertificateValidationCallback = RemoteCertificateValidationCallback;
3539
#endif
3640
}
3741

@@ -40,7 +44,8 @@ public MobileServiceClient(string appUrl, string appKey) : base(appUrl)
4044
/// </summary>
4145
public MobileServiceClient(string appUrl) : base(appUrl)
4246
{
43-
AppUrl = appUrl;
47+
AppUrl = appUrl;
48+
Debug.Log("AppUrl: " + AppUrl);
4449

4550
// required for running in Windows and Android
4651
#if !NETFX_CORE || UNITY_ANDROID
@@ -49,6 +54,14 @@ public MobileServiceClient(string appUrl) : base(appUrl)
4954
#endif
5055
}
5156

57+
/// <summary>
58+
/// Using factory method forces app url to be changed from 'http' to 'https' url
59+
/// </summary>
60+
public static MobileServiceClient Create(string appUrl)
61+
{
62+
return new MobileServiceClient (ForceHttps (appUrl));
63+
}
64+
5265
public override string ToString()
5366
{
5467
return this.BaseUrl;
@@ -93,6 +106,14 @@ public void Login(MobileServiceAuthenticationProvider provider)
93106
this.ExecuteAsync(request, callback);
94107
}
95108

109+
/// <summary>
110+
/// When you copy the URL is is 'http' by default, but its preferable to use 'https'
111+
/// </summary>
112+
private static string ForceHttps(string appUrl)
113+
{
114+
return Regex.Replace(appUrl, "(?m)http://", "https://");
115+
}
116+
96117
/// <summary>
97118
/// Mobile Service uses an AppKey, but App Service does not.
98119
/// </summary>
@@ -117,4 +138,4 @@ private bool RemoteCertificateValidationCallback(System.Object sender, X509Certi
117138
#endif
118139

119140
}
120-
}
141+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Collections;
33
using RestSharp;
44

5-
namespace Unity3dAzure.MobileServices
5+
namespace Unity3dAzure.AppServices
66
{
77
public class ZumoRequest : RestRequest
88
{

Assets/MobileServices/model/AccessToken.cs renamed to Assets/AppServices/model/AccessToken.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Unity3dAzure.MobileServices
1+
namespace Unity3dAzure.AppServices
22
{
33
public class AccessToken
44
{

Assets/MobileServices/model/MobileServiceUser.cs renamed to Assets/AppServices/model/MobileServiceUser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Unity3dAzure.MobileServices
1+
namespace Unity3dAzure.AppServices
22
{
33
public class MobileServiceUser
44
{

Assets/MobileServices/model/ResponseError.cs renamed to Assets/AppServices/model/ResponseError.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Unity3dAzure.MobileServices
1+
namespace Unity3dAzure.AppServices
22
{
33
public class ResponseError
44
{
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Unity3dAzure.MobileServices
1+
namespace Unity3dAzure.AppServices
22
{
33
public class User
44
{

0 commit comments

Comments
 (0)