i started using asset bundles and i managed to make one and to stream one into my game. i have some questions though. since my assetbundle containts a lot of meshes, how to get certain mesh from the bundle? also i would like to stream the assetbundle in such manner that meshes start to appear as soon as they are loaded even if whole assetbundle is not loaded yet? does this make any sense?
first here is a little explanation for the beginners looking to get into asset bundles. this is what you need:
get these two scripts from the project that comes with unity:
1.AutomatedExportResources
2.ExportResource
you can look it up in the unity installation folder.
in your project, make folder “Editor” and place there these two files. When you do that, “Build asset bundle from selection” option will appear under “assets” menu in the top left corner of unity. that means that if you select a prefab, and choose this option it will build assetbundle which you will use later on. try it, make an asset bundle from prefab. upload it to your server.
this script is the minimal script that will download assetbundle from the web:
var www=new WWW(url);
yield www;
var object=Instantiate([url]www.assetBundle.mainAsset[/url]);
url is the location of the asset bundle on your server.
you can use this piece of code to get the information about the progress of download:
function OnGUI(){
var progress = parseInt([url]www.progress[/url] * 100);
GUI.Label(Rect(10,10,200,100),"Downloaded: " + progress.ToString()+"%");
}
just make sure www is global for the script.
i hope this will clear basic things when get into asset bundles. i am a beginner too and i had trouble to get it, since there is not much info about it…
now, the problem that i have is this.
i have 10 asset bundles, i want to show them, one after another, as soon as one is downloaded, show it and proceed to next one…
i guess that has to be in the update func. i tried it there, but i get error that update func cant be coroutine. so i separated the code in the other function. then i got into problem of arrays…
so here is the code i have:
//SERVERINFO
var url : String = "www.serverinfo.com/unity/";
var assetBundleName : Array;
var www:WWW;
var loadingDone : boolean = false;
function Awake(){
assetBundleName= new Array();
assetBundleName[0]="ABundle1.unity3d";
assetBundleName[1]="ABundle2.unity3d";
}
function Start () {
GetStreamData(url+assetBundleName[0]);
}
function Update(){
if(!loadingDone){
for(var i=0;i<assetBundleName.length;i++){
GetStreamData(url+assetBundleName[i]);
}
loadingDone=true;
}
}
function GetStreamData(url : String){
www=new WWW(url);
yield www;
object=Instantiate([url]www.assetBundle.mainAsset[/url]);
}
function OnGUI(){
var progress = parseInt([url]www.progress[/url] * 100);
GUI.Label(Rect(10,10,200,100),"Downloaded: " + progress.ToString()+"%");
}
any ideas i might try?
First I want to thank you Mr, pretender
I am beginer, i craete this files
1.AutomatedExportResources
2.ExportResource
the question is what inside these files?
thank you Again