I broke the application into the main and AssetBundle, I load them when I first start it.

I use for this the following code

void Download(Action callback) { uwr = UnityWebRequestAssetBundle.GetAssetBundle("https://MyUrl"); uwr.SendWebRequest(); _coroutine.StartCoroutine(CheckProgress(callback)); } IEnumerator CheckProgress(Action callback) { while (!uwr.isDone) { yield return null; Debug.LogError(uwr.downloadProgress * 100 + "%"); } _bundle = DownloadHandlerAssetBundle.GetContent(uwr); callback(); } 

Progress is successfully shown and reaches the end, the game starts and runs with bundles.

But when you restart everything repeats! The official documentation of the unit says that UnityWebRequest caches all the bundles locally and upon restart it treats it the same. But for some reason, I download them again every time. What's the matter, how to fix it, and how to at least check for the presence of bundles on the local device? Platform - Editor and Android Device

1 answer 1

Used the wrong constructor for cached bundles. Here's how

 void Download(Action callback) { uwr = UnityWebRequestAssetBundle.GetAssetBundle("https://MyUrl"); //Вот сюда надо добавить одну строчку uwr.downloadHandler = new DownloadHandlerAssetBundle(url, 0,0); uwr.SendWebRequest(); _coroutine.StartCoroutine(CheckProgress(callback)); } IEnumerator CheckProgress(Action callback) { while (!uwr.isDone) { yield return null; Debug.LogError(uwr.downloadProgress * 100 + "%"); } _bundle = DownloadHandlerAssetBundle.GetContent(uwr); callback(); } 

Provided that we ignore version checking. Otherwise, it will be necessary to substitute the arguments in place of the first zero — its. If the version of the bundles do not match, they will be pumped.