Game Development Reference
In-Depth Information
StartCoroutine(WaitForServerResponse(new
WWW(_phpUrl,_wwwForm),null));
}
// C# user:
public override void SaveUserData ( UserData user ) {
_wwwForm = new WWWForm();
// Calling PHP for posting score action
_wwwForm.AddField("action","PostScore");
// Encrypt with MD5
_wwwForm.AddField("hash",MD5.Md5Sum(user.name + "-"
+ user.score.ToString() + "-" + _hashKey));
_wwwForm.AddField("score",user.score);
_wwwForm.AddField("name",user.name);
StartCoroutine(WaitForServerResponse(new
WWW(_phpUrl,_wwwForm),null));
}
5. From the preceding code, we have the function to send data. Now, we will create
the function to load data. Before creating the function to load data, we need to
create the ParseData() function, which will be used to parse the XML data
that is sent from the server. Let's add the following function:
// Unity JavaScript user:
private function ParseXMLData ( xmlText : String)
{
Debug.Log("XML Text = " + xmlText);
XMLParser.Parse(xmlText);
if (XMLParser.users != null) {
_users.AddRange(XMLParser.users);
}
_isLoaded = true;
}
// C# user:
Search WWH ::




Custom Search