Exemplo n.º 1
0
    private IEnumerator GrabTexture(ImageTodo currentTodo)
    {
        Texture2D myTexture = new Texture2D(128, 128, TextureFormat.DXT1, false);

        if (currentTodo.url != null && currentTodo.url.Length > 1)
        {
            UnityWebRequest www = UnityWebRequestTexture.GetTexture(currentTodo.url);
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                myTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;
                currentTodo.callback(myTexture);
                isGrabbing = false;
            }
        }
        else
        {
            isGrabbing = false;
        }
    }
Exemplo n.º 2
0
 private void Update()
 {
     if (imageTodos.Count > 0 && isGrabbing == false)
     {
         ImageTodo currentTodo = imageTodos.Dequeue();
         isGrabbing = true;
         StartCoroutine(GrabTexture(currentTodo));
     }
 }