Ejemplo n.º 1
0
    public IEnumerator GetTexture2D(string url, IWebRequestForTextureCallBack callBack)
    {
        UnityWebRequest        webRequest = new UnityWebRequest(url);
        DownloadHandlerTexture texDl      = new DownloadHandlerTexture(true);

        webRequest.downloadHandler = texDl;
        yield return(webRequest.SendWebRequest());

        if (webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
        {
            callBack.WebRequestForTextureFail(url, webRequest.error);
        }
        else
        {
            callBack.WebRequestForTextureSuccess(url, texDl.texture);
        }
    }
Ejemplo n.º 2
0
    public IEnumerator GetTexture2D(string url, IWebRequestForTextureCallBack callBack)
    {
        UnityWebRequest        webRequest = new UnityWebRequest(url);
        DownloadHandlerTexture texDl      = new DownloadHandlerTexture(true);

        webRequest.downloadHandler = texDl;
        yield return(webRequest.SendWebRequest());

        if (webRequest.isHttpError || webRequest.isNetworkError)
        {
            callBack.WebRequestForTextureFail(url, webRequest.error);
        }
        else
        {
            callBack.WebRequestForTextureSuccess(url, texDl.texture);
        }
    }