Using system.collections;using system.collections.generic;using unityengine;using Unityeditor;public class exportassetbundles:monobehaviour{//Add menu in Unity Editor [MenuItem ("Assets/build assetbundle from Selection")] static void Exportresource () {//Open Save panel, string path = Editorutility.savefilepanel ("Save Resource", String. Empty, "New Resource", "Assetbundle"); if (path. Length > 0) {//Select the object to be packaged object[] selections = Selection.getfiltered (typeof (object), Selec Tionmode.deepassets); Packaged Buildpipeline.buildassetbundle (selection.activeobject, selections, path, Buildassetbundleoptions.completea Ssets | Buildassetbundleoptions.collectdependencies, buildtarget.standalonewindows); }} [MenuItem ("Assets/save Scene")] static void Exportscene () {String path = Editorutility.savefilepan El ("Save Resource", String. Empty, "New Resource", "Unity3d"); if (path. Length > 0) { object[] selection = selection.getfiltered (typeof (Object), selectionmode.deepassets); Specific to the project, you need to dynamically set string[] scenes = {"Assets/scene1.unity"}; Buildpipeline.buildplayer (scenes, Path, buildtarget.standalonewindows, Buildoptions.buildadditionalstreamedscenes ); } }}
Unity 4.x Resource Packaging