I still new using UnityWebRequest to download and load asset bundle from server container. The problem is the value for the download progress always 0. How can I get the value for download progress?
Code Below what I try to download and get the download progress.
//Method to download the assetbundle
IEnumerator DownloadAsset()
{
string url = here the URL for asset bundle;
using (var uwr = new UnityWebRequest(url, UnityWebRequest.kHttpVerbGET))
{
uwr.downloadHandler = new DownloadHandlerAssetBundle(url, 36, 0);
UnityWebRequestAsyncOperation operation = uwr.SendWebRequest();
yield return StartCoroutine(DownloadProgress(operation));
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(uwr);
{
print("Get asset from bundle...");
}
//Load scene
uwr.Dispose();
print("ready to Load scene from asset...");
StartCoroutine(LoadSceneProgress("Example"));
bundle.Unload(false);
}
}
//Method for download progress
IEnumerator DownloadProgress(UnityWebRequestAsyncOperation operation)
{
while (!operation.isDone)
{
progressBar.color = Color.red;
downloadDataProgress = operation.progress * 100;
progressBar.fillAmount = downloadDataProgress / 100;
print("Download: " + downloadDataProgress);
yield return null;
}
Debug.Log("Done");
}
I expect to display download progress bar or download percentage to show the download progress on screen. but the download progress value always 0.