Skip to content Skip to sidebar Skip to footer

Unitywebrequest.sendwebrequest Doens't Send On Mobile

I am downloading Assetbundles using the UnitywebRequest method from HTTPS, however the UnityWebRequest.SendWebRequest seems to take its sweet time to actually start receiving any d

Solution 1:

Always trouble with UnityWebRequest - sometimes nothing makes sense with UnityWebRequests...

You can try to replace

UnityWebRequestwww=newUnityWebRequest(FileManager.RequestFile(path));

with

UnityWebRequestwww=newUnityWebRequestAssetBundle(FileManager.RequestFile(path), 0);

Optional for testing:

Also I think your while loop is not "save" to catch the network error. I would prefer the following like mentioned in the documentation

UnityWebRequest www = new UnityWebRequestAssetBundle(FileManager.RequestFile(path);
yieldreturn www.SendWebRequest();

if (request.isNetworkError || request.isHttpError)
{
    Debug.Log(www.error.ToString());
}
else
{
    // for testing only // if yield return www.SendWebRequest(); is working as expected www.isDone = true here!while (!www.isDone)
    {
        Debug.Log("Something is wrong! "  + www.responseCode);
        yieldreturnnewWaitForSeconds(0.1f);
    }
    // do whatever you want
}

Hope this helps.

Post a Comment for "Unitywebrequest.sendwebrequest Doens't Send On Mobile"