//Start Coroutine to get www result public WWW getxml(string url) { WWW www = new WWW(url); Requestwww requestwww = new Requestwww(); StartCoroutine(requestwww.WaitForRequest(www)); return(www); }
// Use this for initialization void Start() { //This call get all quizz id into xml string url = "http://kidesolutions.fi/lingoquizGetAllQuizzID.php"; Requestwww wwwcall = gameObject.AddComponent <Requestwww>(); WWW link = wwwcall.getxml(url); while (!link.isDone) { //Do nothing Debug.Log("wait for completion"); if (link.isDone) { //Get string of xml from server, contain only one value, quiz id of weekquiz. xmltext = link.text; break; } } Debug.Log("Here is all Quizz ID" + xmltext); }
// Use this for initialization //This call get quizz by id into xml public string return_quizz(string id) { string url2 = "http://kidesolutions.fi/lingoquiz/GetQuizzbyID.php?id="; url2 = url2 += id; Requestwww wwwcall = gameObject.AddComponent <Requestwww>(); WWW quiz = wwwcall.getxml(url2); string quiz_text = ""; while (!quiz.isDone) { //Do nothing Debug.Log("wait for completion"); if (quiz.isDone) { //Get string of xml from server, contain quizz data. quiz_text = quiz.text; Debug.Log(quiz_text); break; } } return(quiz_text); }