• buildpipeline.buildassetbundleexplicitassetnames 编译资源包带有资源名 - 脚本手册 - -【游戏蛮牛】-游戏出海,ar增强现实,虚拟现实,unity3d,unity3d教程下载首选u3d,unity3d官网 - Powered by Discuz!


    buildpipeline.buildassetbundleexplicitassetnames 编译资源包带有资源名

    2015-1-3 22:07| 发布者: 杨炎| 查看: 2719| 评论: 0|原作者: 蛮牛|来自: unity3d脚本manual

    摘要: buildpipeline.buildassetbundleexplicitassetnames 编译资源包带有资源名static functionbuildassetbundleexplicitassetnames(assets:object,assetnames: string,pathname: string,options:buildassetbundleoptions ...

    buildpipeline.buildassetbundle" target="_blank" class="relatedlink">assetbundleexplicitassetnames 编译资源包带有资源名

    static functionbuildassetbundleexplicitassetnames(assets:object[],assetnames: string[],pathname: string,options:buildassetbundleoptions=buildassetbundleoptions.collectdependencies|buildassetbundleoptions.completeassets,targetplatform:buildtarget=buildtarget.webplayer) : bool


    builds an asset bundle, with custom names for the assets (unity pro only).

    生成一个资源包,带有资源的自定义名称(仅用于unity pro)。

    creates a compressed unity3d file that contains a collection of assets. assetbundles can contain any asset found in the project folder. in the assetnames parameter, supply an array of strings of the same size as the number of assets. these will be used as asset names, which you can then pass tobuildassetbundleto just use the asset's path names instead. the compressed asset bundle file will be saved at pathname. options allows you to automatically include dependencies or always include complete assets instead of just the exact referenced objects.



    // c# example

    // builds an asset bundle from the selected folder in the project view.

    // bare in mind that this script doesnt track dependencies nor is recursive



    using unityengine;

    using unityeditor;

    using system.io;

    public class buildassetbundlesfromdirectory {

    [@menuitem("asset/build assetbundles from directory of files")]

    static void exportassetbundles () {

    // get the selected directory


    string path = assetdatabase.getassetpath(selection.activeobject);

    debug.log("selected folder: " + path);

    if (path.length != 0) {

    path = path.replace("assets/", "");

    string [] fileentries = directory.getfiles(application.datapath+"/"+path);

    foreach(string filename in fileentries) {

    string filepath = filename.replace("", "/");

    int index = filepath.lastindexof("/");

    filepath = filepath.substring(index);


    string localpath = "assets/" + path;

    if (index > 0)

    localpath += filepath;

    object t = assetdatabase.loadmainassetatpath(localpath);

    if (t != null) {


    string bundlepath = "assets/" + path + "/" + t.name + ".unity3d";

    debug.log("building bundle at: " + bundlepath);

    // build the resource file from the active selection.



    (t, null, bundlepath, buildassetbundleoptions.completeassets);