Game Development Reference
In-Depth Information
Getting the data from the server is much simpler. To do so, write a simple coroutine to
download the data that you can call when it's needed:
IEnumerator GetSavedDataFromWWW()
{
string url = "http://mybackendserver.com/
DownloadSaveData.php";
WWW www = new WWW(url);
yield return www;
if (www.error == null)
{
var restoredData = DeserializePlayerState(www.bytes);
}
else
{
Debug.LogError("Error: " + www.error);
}
}
Note that the examples are over-simplified to show you how the WWW class works.
For more information about the WWW class, see the Unity scripting reference guide at ht-
tps://docs.unity3d.com/Documentation/ScriptReference/WWW.html .
Tip
If you would rather not roll your services, you can use backends such as Azure for which
some budding teams have put together plugins for Unity3D. Check them out at ht-
tp://www.bitrave.com/azure-mobile-services-for-unity-3d/ .
There is even a promising Unity implementation that connects to Google Services as well
at https://github.com/kimsama/Unity-GoogleData .
I've not seen any implementation for AWS as yet, but keep an eye out for this or use the
previous examples as a primer to start your own; if you do see any, please share!
Search WWH ::




Custom Search