- Home /
Load Assetbundles all at once.
Is there a chance to Load All Assetbundles from a remote at once? I'm creating assetbundles for every gameObject to have full update flexibility and therefore need to load many assetbundles in case of an update. If so, is it possible to only load assetbundles with a certain name?
The way i'm doing it right now:
WWW www = new WWW(_remoteAssetBundlesPath);
yield return www;
Answer by Bunny83 · Sep 06, 2018 at 02:01 PM
You can issue as many loading request as you want as they are asynchronous operations. However you most likely will run into an issue of max concurrent downloads for the same session on your server. Most HTTP servers have a limit of 2 connections per client / session. So if you try to load 10 things at the same time 8 might have to wait until one of the current downloads have finished. This can't be answered in general as it depends on the server. Unity doesn't have a limit (that i know) of hom many concurrent downloads it can carry out.
To load several files at the same time you may either start a new coroutine for every file or use a single one where you create the WWW requests all at once and store the www objects in a List. Note that you may not call yield return on the www objects but rather iterate through the list from time to time to see which have finished downloading. The exact implementation would highly depend on the desired usage. So where and how do you use the downloaded bundles. How are you going to keep track of which bundle belongs to what.
Keep in mind that there is the LoadFromCacheOrDownload method which only works for assetbundles and is specifically designed to load the bundle and store it on the users disk. for later use. Though you have to provide a version for each bundle in order to know when a bundle needs to be loaded again. Otherwise it will always load the cached version. One way is to store a json file or something similar on the server which is always loaded first which only contains the bundle names (or urls) as well as the current version on the server. Of course you have to ensure to increase the version when you change the file on the server.
It's generally recommended to cache large files since each download produces traffic on your server. This could either produce more costs for you or you may run into the traffic limitations of your server. Also depending on the server capacity if many ppl download everything every time they start your game the download speed may suffer. In general loading many many small files will always be slower than loading one or a few larger files. The HTTP protocol has quite some overhead A large continous chunk of data also can be comressed better which reduces the overall size a bit. However if you plan to provide frequent updates to individual files you really should cache them and only load the new ones.