예제 #1
0
        public void DownloadXmlFile()
        {
            WWW www = new WWW(url);

            while (!www.isDone)
            {
            }
            CollectionReader.LoadXmlFromText(www.text);
        }
    /// <summary>
    /// Download an XML file from a specified URL and populate a CollectionReader with the contents of the
    /// XML file
    /// </summary>
    /// <param name="url">The absolute path to the XML file, with the scheme (e.g. file://, http://, etc.) </param>
    IEnumerator DownloadXml(string url)
    {
        Debug.Log("Downloading some XML from " + url);
        UnityWebRequest www = UnityWebRequest.Get(url);

        yield return(www.Send());

        if (www.isError)
        {
            // TODO: Echo the error condition to the user
            Debug.Log("Couldn't download XML file at " + url + "\n" + www.error);
        }
        else
        {
            CollectionReader.LoadXmlFromText(www.downloadHandler.text);
            Debug.Log("Downloaded some XML from " + url);
            GetCollections();
        }
    }