Game Development Reference
In-Depth Information
void ParseXMLData ( string xmlText )
{
Debug.Log("XML Text = " + xmlText);
XMLParser.Parse(xmlText);
if (XMLParser.users != null) {
_users.AddRange(XMLParser.users);
}
_isLoaded = true;
}
6. Then, we will add the last method, LoadUserData() , to load the user data
from the server, wait until it is finished, and then call ParseXMLData() to
parse the data to _users . Let's add the following code:
// Unity JavaScript user:
override function LoadUserData () {
super.LoadUserData();
_isLoaded = false;
_wwwForm = new WWWForm();
// Calling PHP for getting score action
_wwwForm.AddField("action","GetScore");
StartCoroutine(WaitForServerResponse(new
WWW(_phpUrl,_wwwForm),ParseXMLData));
}
// C# user:
public override void LoadUserData () {
base.LoadUserData();
_isLoaded = false;
_wwwForm = new WWWForm();
// Calling PHP for getting score action
_wwwForm.AddField("action","GetScore");
StartCoroutine(WaitForServerResponse(new
WWW(_phpUrl,_wwwForm),ParseXMLData));
}
Search WWH ::




Custom Search