Game Development Reference
In-Depth Information
Backing up to the Web
An alternative to the basic saving of data to a disk, a lot of games now (especially if they
are targeting multiple platforms) support a web backend to store a player's data. It doesn't
need to be heavy; just use a player name/ID key and store the serialized data.
The benefit of this approach is that the player can continue playing on any device, regard-
less of which device they were last playing on.
Tip
Halo Spartan Assault implemented this feature and its sales skyrocketed because players
on Windows Phones could switch to playing on their desktop or Xbox when they got
home or vice versa. A big selling point!
Implementing this approach depends on the backend service you use for your data; wheth-
er you roll your own or use Azure MWS, Amazon Web Services, or Parse, which all have
plugins that work for Unity3D.
The simplest approach is to use the serialization methods described previously and post
your data to a backend web service using the Unity WWW class. As a full example would
be too complex to demonstrate, what follows are just some code snippets of the available
Unity functions.
Note
Granted you will have to write your web service on a server to accept this data, which is
out of scope of this topic, but if you search on www.codeproject.com or stackover-
flow.com , you will find many good examples of such implementations.
You could post the serialized data direct to a service using a function similar to the follow-
ing code (as an example only):
void UploadSaveData1()
{
string url = "http://mybackendserver.com/Upload.php";
var playerSerializedState =
SerializerHelper.Serialise<PlayerSaveState>
(currentPlayer.GetPlayerSaveState());
WWW www = new WWW(url, playerSerializedState);
Search WWH ::




Custom Search