I’m trying to prioritize downloading certain textures from png files.
UnityWebRequestAsyncOperation has a priority field, but it seems to have no effect after the request is sent.
The problem is the only way to get the the field is to issue SendWebRequest(). Help please?
using (UnityWebRequest request = UnityWebRequest.Get(uri))
{
UnityWebRequestAsyncOperation op = request.SendWebRequest();
op.priority = priority;
yield return op;
if (request.isNetworkError || request.isHttpError)
{
result?.Invoke(null);
}
else
{
result?.Invoke(request.downloadHandler.data);
}
}
If you look at the docs, it just controls which get started first if you start two of them the same frame.
They will however, generally ALL get started on that same frame.
Once started, priority makes no matter, and from then on your time to completion is going to depend on network whimsy and weather, and total size of data transfer.
You could just do this but it could get pretty complicated. Don’t you just want everything as fast as possible? Unless the network transfer maxes out, downloading two textures at once will hardly be any longer than just one, especially on mobile networking, where plenty of other factors (cel tower reconnection, congestion, etc.) come into play.
There is no built-in support for this.
What you can do, is start the priority requests first and wait for them to make some download progress before starting the remaining ones. That I believe will give you a quite good prioritization. For additional priority, you can monitor progress and abort the lower priority request in case you hit bandwidth limits.