Hi, I'm testing some code to get xml data from a server using the WWW() function from here http://unity3d.com/support/documentation/ScriptReference/WWWForm.html The problem is that Unity'console keeps telling me: A local variable named `textFromServer' is already defined in this scope. This makes me think that it can't be used the instruction 'yield' inside the start() function... because this problem doesn't happen when I delete the line that has yield written but the file needs time to be downloaded.
// Use this for initialization
//void Start () { Before
IEnumerator Start() {
//Load XML data from a URL
string url = "http://www.domain.com/file.xml?argumen1=98769";
WWW textFromServer = new WWW(url);
//Load the data and yield (wait) till it's ready before we continue executing the rest of this method.
//yield textFromServer; Before
yield return textFromServer;
if (textFromServer.error == null) {
//Sucessfully loaded the XML
Debug.Log("Loaded following XML " + textFromServer.text);
}
}
Thanks for your help.