buildpipeline.buildstreamedsceneassetbundle 编译流场景资源包

2015-1-3 22:27| 发布者: 杨炎| 查看: 3280| 评论: 0|原作者: 蛮牛|来自: yzc88亚洲城脚本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


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 yzc88亚洲城 file.


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


// build a streamed yzc88亚洲城 file. this contain one scene that can be downloaded

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



static function mybuild(){

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

buildpipeline.buildstreamedsceneassetbundle( levels, "streamed-level1.yzc88亚洲城", 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.


function start () {

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

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



var download =www.loadfromcacheordownload("亚洲城", 5);

yield download;

// handle error

if (download.error != null)





// 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.



var bundle = download.assetbundle;

// load the level we have just downloaded