Question by
sreeharim · Dec 30, 2020 at 12:08 PM ·
scripting problemiosassetbundlewebrequest
unitywebrequest and ARFoundation In IOS device get stuck randomly
trying to download Asset bundle from server using unitywebrequest, sometimes it is unable to download manifest file randomly, and can't able to connect the server for further until kill the app in mobile. Here I am using Arfoundation in the app Same code working fine in Android and webgl, getting issue only in ios. Please help me in this. Here is my code
IEnumerator DownloadAssetBundleFromServerCallFunc ()
{
UnityWebRequest manifestWebRequest = UnityWebRequest.Get(url + ".manifest");
yield return manifestWebRequest.SendWebRequest();
while (!manifestWebRequest.isDone) { yield return null; }
string manifestString = manifestWebRequest.downloadHandler.text;
Hash128 hash = Hash128.Compute((Random.value * int.MaxValue).ToString());
foreach (string line in manifestString.Split('\r', '\n'))
{
if (line.StartsWith(" Hash: "))
{
try
{
hash = Hash128.Parse(line.Substring(9));
Debug.Log("Successfully parsed hash. Value is " + hash + ".");
}
catch { Debug.LogError("Error when parsing hash; skipping parse and forcing download."); }
break;
}
}
Debug.Log("Downloading from " + url + "...");
UnityWebRequest www = UnityWebRequestAssetBundle.GetAssetBundle(url, hash);
StartCoroutine(DownloadBarProgress(www));
yield return www.SendWebRequest();
while (!www.isDone) {
yield return null;
}
if (myLoadedAssetBundle != null) {
myLoadedAssetBundle.Unload(true); //scene is unload from here
if (www.error == null) {
myLoadedAssetBundle = DownloadHandlerAssetBundle.GetContent(www);
}
}
}
Comment