i am getting better and better but sometimes i need a help from experts to help me untangle from the mess i got myself into 
like the subjects states i want my asset bundles to show one after another and to load in the update loop.
i know i should work out this problems with arrays but i want first to get it working and then i will improve it…
here is the code that doesnt work great, it loads and displays only first asset and then nothing, i think i dont really understand yield very good. any help in resolving this issue is appreciated…
var assetBundle : AssetBundle;
var instanced : Object;
//var progress;
var progressString : String;
var download1:WWW;
var download2:WWW;
var loadFirst : boolean = false;
var loadSecond : boolean = false;
function Update(){
if(!loadFirst){
loadFirst=true;
StartDownload("Prefab1.unity3d",download1);
if(download1.isDone)
loadSecond=true;
}
if(loadSecond){
loadSecond=false;
StartDownload("Prefab2.unity3d",download2);
}
}
function StartDownload(url:String,download : WWW){
if (url.IndexOf ("file://") == 0 || url.IndexOf ("http://") == 0)
download = new WWW (url);
if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.WindowsWebPlayer)
download = new WWW (url);
else if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
download = new WWW ("file://" + Application.dataPath + "/" + url);
progressString=parseInt(download.progress*100).ToString();
yield download;
assetBundle = download.assetBundle;
if (assetBundle != null)
{
var go : Object = assetBundle.mainAsset;
if (go != null)
instanced = Instantiate(go);
else
Debug.Log("Couldnt load resource");
}
else
{
Debug.Log("Couldnt load resource");
}
}
function OnGUI()
{
//progress=parseInt(download.progress*100);
GUI.Label(Rect(5,5,200,200),"Downloaded: " + progressString +"%");
}
i also wonder why this line in the StartDownload function doesnt give any value:
progressString=parseInt(download.progress*100).ToString();
it should track download progress but it doesnt
aslo i am wondering about the yield statement
does that mean that if i have something like this:
for(var i=0;i<10;i++){
yield StartDownload();
}
it will wait for StartDownload to finish whatever it is doing to go to the next loop and in the same time it will execute any other lines of code, for example in the update loop?
if you test it locally without a real network (or the corresponding network emulation) the progress will jump from 0 to 1 instantly as “file is there” = 100%
And the yield there makes it wait till the other function (startdownload) returns while the rest of the program continues without being touched basically
i tried it on the network too and progress isnt shown…that is why i wonder why? it should work though
but that is all secondary…primary is to figure out how to show asset bundles one after another, or the logic behind it…now it isnt looking very good, in the update loop
Potentially you had it fully cached (ensure to test in the browser and clear its cache).
if you do it with a standalone / editor test with the assetbundle being right there it will take the “cached one” basically.
as for loading one after another: your for loop there should do that job but not in update as update is called over and over again.
what you want to do is put it into a new function and start that function through StartCoroutine from function Start()
ok, here it goes, i erased cache in browser and tried this, progress just sits there at 0%. i know that this worked when i had just one asset to download, and when i was getting download.progress it worked (i was doing that from OnGUI since download variable was accessible), so i dont know why now isnt working when it is in the StartDownload()
for loading one after another: if i download assets in Start(), doesnt that mean that they will show up all at once when Update loop starts?
and i made a function LoadObjects() and put all loading stuff there, and put that function in Update()… that should work? right?
there is no “update loop”
update is called every single frame for every single object in the game
looping in there is asking for serious problems
you can only use yield in there because JS hides what it really does, though that leads to even more confusion on how to solve this kind of problem
i meant to say update function…
Just wanted to clarify that 
And no it won’t be a problem.
Update has nothing to do with the assetbundle handling then anymore. its all done in the coroutine
ok, since everything is working except the download.progress i tried to go with arrays…
here is how i did it:
//i am loading just two prefabs for now
var PrefabURL = new String[1];
var WWWObject = new WWW[1];
var instancedObject = new Object[1];
initialize them
function Awake(){
PrefabURL[0]="Prefab0.unity3d";
PrefabURL[1]="Prefab1.unity3d";
}
start the loading…
function Start () {
LoadObjects();
}
function LoadObjects() - coroutine
function LoadObjects(){
for(var i=0;i<2;i++){
yield StartDownload(PrefabURL[i],WWWObject[i],instancedObject[i]);
}
}
StartDownload is unchanged…
it loads first object and throws me the IndexOutOfRangeException - Array Index is out of range…
it seems ok to me…what is wrong???
you create the arrays with a size of 1 and access 2 elements.
the other thing is that you create the arrays but unless you also fill them with objects they will end with a nullref exception (like using WWWObject[0] when you have not before had a WWWObject[0] = new WWW(…) for example.