找回密碼
 注冊帳號

掃一掃,訪問微社區

buildpipeline.buildstreamedsceneassetbundle 編譯流場景資源包

2015-1-3 22:27| 發布者: 楊炎| 查看: 3410| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: buildpipeline.buildstreamedsceneassetbundle 編譯流場景資源包static functionbuildstreamedsceneassetbundle(levels: string,locationpath:string,target:buildtarget) :stringdescription描述builds one or more ...

buildpipeline.buildstreamedsceneassetbundle" target="_blank" class="relatedlink">assetbundle 編譯流場景資源

static functionbuildstreamedsceneassetbundle(levels: string[],locationpath:string,target:buildtarget) :string

description描述

builds one or more scenes and all it's dependencies into a compressed asset bundle.

編譯一個或多個場景和所有它依賴的壓縮資源包。

the scene assetbundle can be built for any target platform and always creates a single compressed unity3d file.

該場景資源包可以內置任意目標平臺,并總是創建單一壓縮的unity3d文件

the scene can be downloaded and loaded using the www class. you can usewww.loadfromcacheordownloadto cache the downloaded scene after it has been downloaded.

該場景可以被下載并使用www類加載。可以使用www.loadfromcacheordownload已經被下載后,來緩存下載的場景。

// build a streamed unity3d file. this contain one scene that can be downloaded

// on demand and loaded once it's asset bundle has been loaded.

//構建一個流unity3d文件,包含一個場景,可以按需下載,一旦資源包加載時加載。

@menuitem("build/buildwebplayerstreamed")

static function mybuild(){

var levels : string[] = ["assets/level1.unity"];

buildpipeline.buildstreamedsceneassetbundle( levels, "streamed-level1.unity3d", buildtarget.webplayer);

}

when downloading the built compressed file, you need to callwww.assetbundlein order to make the scene available to theapplication.loadlevel() andapplication.loadleveladditive() functions.

當下載內置的壓縮文件,必須調用www.assetbundle以使場景application.loadlevel()和application.loadleveladditive()函數可用。

function start () {

// download compressed scene. if version 5 of the file named "streamed-level1.unity3d" was previously downloaded and cached.

// then unity will completely skip the download and load the decompressed scene directly from disk.

//下載壓縮的場景。如果名為streamed-level1.unity3d的文件版本為5,預先下載并緩存。

//然后unity將完全跳過下載并直接從磁盤加載解壓的場景。

var download =www.loadfromcacheordownload("http://mywebsite.com/streamed-level1.unity3d", 5);

yield download;

// handle error

if (download.error != null)

{

debug.logerror(download.error);

return;

}

// in order to make the scene available from loadlevel, we have to load the asset bundle.

// the assetbundle class also lets you force unload all assets and file storage once it is no longer needed.

//為了使場景loadlevel可用,必須加載資源包

//assetbundle類,還可以強制卸載所有的資源和文件存儲,一旦不再需要。

var bundle = download.assetbundle;

// load the level we have just downloaded

//加載剛才下載的關卡

application.loadlevel("level1");

}

相關閱讀

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