Beispiel #1
0
    IEnumerator DownloadWordPictures(string word)
    {
        Debug.Log("starting picture download for " + word);
        string[] urls =
        {
            "https://matthewriddett.com/static/mludlc/pictures/" + word + "/" + word + "1.png",
            "https://matthewriddett.com/static/mludlc/pictures/" + word + "/" + word + "2.png",
            "https://matthewriddett.com/static/mludlc/pictures/" + word + "/" + word + "3.png",
            "https://matthewriddett.com/static/mludlc/pictures/" + word + "/" + word + "4.png",
            "https://matthewriddett.com/static/mludlc/pictures/" + word + "/" + word + "5.png"
        };

        foreach (string url in urls)
        {
            using (UnityWebRequest www = UnityWebRequestTexture.GetTexture(url))
            {
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    Debug.Log(www.error);
                }
                else
                {
                    Texture2D myTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;


                    controller.SetCurrentTexture(myTexture);
                    if (controller.IsTextureSet())
                    {
                        controller.AddNewTexture();
                    }
                    myTexture = null;
                }
            }
        }

        controller.SaveNewWord(tempWordName, tempWordTags);
        Debug.Log("Done downloading word: " + tempWordName);
        controller.ClearTextureList();
        doneImageDownload = true;
    }