LoadAllAssetsAsync from AssetBundle is not really async
We are making a WebGL app that has to use AssetBundles to load props into a scene. The problem is that once the bundle is downloaded the app freezes for around 2.5 MINUTES until the prefabs are loaded into a list... We have tried all the load methods. One by one, all at once, normal and async and we get the same thing every time. It takes a LONG time to load the prefabs. Our current code is:
public IEnumerator LoadPrefabsAsync()
{
print("start loading prefabs");
AssetBundleRequest request = assetBundle.LoadAllAssetsAsync<GameObject>();
yield return request;
prefabs = request.allAssets as GameObject[];
while (!request.isDone)
yield return null;
//List<GameObject> objs = new List<GameObject>();
//foreach (var i in assetNames)
// {
// AssetBundleRequest request = assetBundle.LoadAssetAsync(i);
// objs.Add(request.asset as GameObject);
// yield return null;
// }
//prefabs = objs.ToArray();
//Debug.Log(prefabs.Length + " prefabs from " + assetBundle.name + " loaded.");
prefabsLoaded = true;
yield return null;
}
Has anyone found any kind of workaround or fix or this?
Answer by Hello_ · Jul 26, 2018 at 10:26 AM
How do you load your assetbundle? Could that be the cause for the long loading.
Also don't load all at once. Use Load(name) and wait for the request for each asset.
You could also use request.isDone and check each update or ever other or so.
Your answer
![](https://koobas.hobune.stream/wayback/20220612161719im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Loading asset bundle from sql server 0 Answers
load .unity3d assetbundle from resource folder 0 Answers
Unity Addressables LoadAssetAsync is too slow 1 Answer
Async Level loading issue. 0 Answers
Asynchronous load screen 1 Answer