Some Assetbundle clarifications

There are a list of things I am unsure about re WWW and AssetBundles. I can write code that works by copying examples but am unsure of what is happening under the hood.

Consider this code from the documentation for mainAsset

function Start () {
var www = new WWW ("http://myserver/myBundle.unity3d");
yield www;
// Get the designated main asset and instantiate it.
Instantiate([url]www.assetBundle.mainAsset[/url]);
}

(1) Is “yield www” equivalent to something like “while(!www.IsDone) yield 0;” ?

(2) How done is isDone? Clearly you can access the assetBundle after this, but assetBundles have functions like LoadAsyc, implying to me the assetBundle is really just an interface to other things you can load at this point. At this point are these assets still to be downloaded from across the web to your local machine by calling Load or LoadAsync?

(3) In this example mainAsset is loaded immediately as an object. Is this equivalent to assetBundle.Load(nameOfMainAsset)? What if you wanted to load the mainAsset using LoadAsyc? Or is mainAsset a special case that is fully loaded at the point that www.isDone is true, making LoadAsync unnecessary?

(4) I am hazy about how bundles share assets from other bundles. Just begun researching Push/PopAssetDependencies and there is also something interesting called DeterministicAssetBundle. Anything I can read to understand how I use these? I suspect that deterministicAssetBundle is something I want to use for bundles of assets shared by other bundles.

(5) Just to confirm what I have read elsewhere: C# classes are not included in bundles? If I am intending to define entire levels in bundles, any specialized script logic will not be in the bundle but will instead require the user to download the updated player?

Yes.

isDone on the www instance means that the assetBundle has been fully downloaded and decompressed. Using LoadAsync to actually load objects will not perform any downloading, but for some assets, instantiation is not instantaneous - imaging a big 3d model, which requires lots of textures, shaders and meshes to be uploaded to the graphics card, things like that. That is why it often makes sense to do this in the background using LoadAsync, for smoothest results.

.mainAsset is indeed equivalent to assetBundle.Load(nameOfMainAsset). Again, you may want to use LoadAsync instead, if object loading times are an issue here.

DeterministicAssetBundle was introduced to avoid a problem with conflicting instanceID (which are used to internally identify objects). You probably want to use this when you have a huge world with many objects, and frequently update AssetBundles with different ones which you still need to work with the other ones published earlier.

This is correct.

Hey guys,

I know this is an old thread but I was wondering if you could clarify something : once the assetBundle has been fully downloaded and decompressed, where does it get decompressed to? Is it in memory? disk? If in memory, then Load should be pretty much instantaneous no? So there’s no need for LoadAsync, unless the loading process does a bunch of other things other than simply transferring a memory pointer (which would be the case if the memory isn’t a binary serialization of the object). If to disk, then I can see why we need a LoadAsync.

El Diablo

bump