Packaged:
①assets new Folder editor and Steamingassets
② Package the selected files:
usingUnityengine;usingUnityeditor;usingSystem.Collections; Public classAssetbundle:monobehaviour {[MenuItem ("Custom editor/create assetbundles Main")] Static voidCreateassetbundlesmain () {object[] Selectedasset= Selection.getfiltered (typeof(Object), selectionmode.deepassets); foreach(Object objinchSelectedasset) { stringSourcePath =Assetdatabase.getassetpath (obj); stringTargetPath = Application.datapath +"/streamingassets"+ Obj.name +". Assetbundle"; if(Buildpipeline.buildassetbundle (obj,NULL, Targetpath,buildassetbundleoptions.collectdependencies)) {Debug.Log (Obj.name+"Success"); } Else{Debug.Log (obj.name+"Failure"); } } }}
Load presets from asset bundle:
1 usingUnityengine;2 usingSystem.Collections;3 4 Public classLoadab:monobehaviour {5 6 //Use this for initialization7 voidStart () {8Startcoroutine (Loadbundle ("file://"+application.streamingassetspath+"/"+"streamingassetsnew Prefab.assetbundle"));9 }Ten One //Update is called once per frame A voidUpdate () { - - } the PrivateIEnumerator Loadbundle (stringpath) { -WWW load =NewWWW (path); - yield returnload; -Gameobject obj = gameobject.instantiate (load.assetBundle.mainAsset) asGameobject; +Load.assetBundle.Unload (false); - } +}
Unity3d packaging and use of packages