Quantcast
Channel: Questions in topic: "webrequest"
Viewing all articles
Browse latest Browse all 387

UnityWebRequest only does one request at a time

$
0
0
I'm converting some code that was using `WWW` to use `UnityWebRequest`. The code is very simple, just download a png and convert the loaded texture to a sprite. When using `WWW` all requests seem to run at once and complete at about the same time. When using `UnityWebRequest` I can clearly see one image pop in at a time, indicating that only one request is being done at once. I've tested this in the Editor on OS X and on Android, the result is the same on both. Code with `WWW`: var request = new WWW(url); yield return request; if (request.error != null) { HandleError(request.error); } else { var texture = request.texture; MakeSpriteFromTexture(texture); } Code with `UnityWebRequest`: var request = UnityWebRequest.GetTexture(url); yield return request.Send(); if (request.isError) { HandleError(request.error); } else { var texture = (Texture2D)((DownloadHandlerTexture)request.downloadHandler).texture; MakeSpriteFromTexture(texture); } The two are almost identical, yet the `WWW` version performs substantially better. Is there anything I'm doing wrong with `UnityWebRequest` that would cause requests to only run one at a time? Thanks!

Viewing all articles
Browse latest Browse all 387

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>