找回密碼
 注冊帳號

掃一掃,訪問微社區

buildpipeline.buildassetbundleexplicitassetnames 編譯資源包帶有資源名

2015-1-3 22:07| 發布者: 楊炎| 查看: 2685| 評論: 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

description描述

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.

創建一個壓縮的unity3d文件,包含資源的集合。資源包可以包含任何項目文件中的資源。在assetnames參數,然后可以傳遞給assetbundle.load加載一個特定的資源。使用buildassetbundle只使用資源的路徑名替代。壓縮的資源包文件將保持在pathname。options允許您自動包括依賴關系或總是包含完整的資源,而不只是準確引用的對象。

參見:buildassetbundle,assetbundle類,www.assetbundle.

// 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);

debug.log(filepath);

string localpath = "assets/" + path;

if (index > 0)

localpath += filepath;

object t = assetdatabase.loadmainassetatpath(localpath);

if (t != null) {

debug.log(t.name);

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

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

// build the resource file from the active selection.

//從激活的選擇編譯資源文件

buildpipeline.buildassetbundle

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

}

}

}

}

}

相關閱讀

文章點評
相關文章
女校游泳队彩金