示例#1
0
    private void LoadImageCallback(string error, Texture2D image)
    {
        if (!string.IsNullOrEmpty(error))
        {
            // TODO: There was an error, show it to users.
            Debug.Log("Error on load image callback");
        }
        else
        {
            controller.SetCurrentTexture(image);
        }

        saveButton.interactable = true;
        CleanUpScroll();
        DisplayGallery();
        Debug.Log("loadimagecallback");
    }
示例#2
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;
    }