- Home /
Why is there no such thing as a LoadAllAsync method?
I want to be able to load all assets in my AssetBundle asynchronously without storing their IDs externally. I have read that LoadAll method does this very nicely but I want to be able to perform the loading asynchronously.
I was surprised to see that there is no such method as LoadAllAsync. The only method that loads assets asynchronously is the LoadAsync method which takes in a name, implying that I have to know the names of the assets I want to load beforehand. Is there any reason why a LoadAllAsync method does not exist?
Answer by Paulius-Liekis · Feb 28, 2012 at 11:50 AM
How are you going to access assets without knowing the names?
As Unity documentation says that one of the tricks is creating a TextAsset in the asset bundle which contains names of all assets.
And with that you would still need to know the name of that one TextAsset right? Anyway, I was just trying to change all my load assets functions to be asynchronous as I thought loadAll will take a long time for a huge asset bundle but it turns out not so (at least for my use case). I was using the WWW class to download the asset bundle file from a local drive and turns out it is the WWW class that blocks and needs to be yielded as shown in the Unity WWW class reference sample code. If that is the case, what would be the use case of loadAsync method since the time-consu$$anonymous$$g import is already done by the WWW class?
Yes, loading it from disk is the slower part, but depending on how many assets and what kind you have in your asset bundle instantiating them can take significant amount of time.
This is nonsensical, Paulius.
Of course, it would be exactly the same as when you use LoadAll ...
you just use .name This is absolutely standard. There'd be no difference at all if they were loading async.
rawArrayOfClips =
Resources.LoadAll("VO/", typeof(AudioClip) ).Cast<AudioClip>().ToArray();
int kRA = rawArrayOfClips.Length;
for(int index=0; index<kRA; ++index)
{
Debug.Log(rawArrayOfClips[index])
it is
staggeringly silly
Unity did not throw in LoadAllAsync. Bad Unity.
Fisyher, you're right that the www class is sort of like an async loader -- pity it hardly works. (Google)