找回密碼
 注冊帳號

掃一掃,訪問微社區

application.loadlevelasync 異步加載關卡

2014-12-31 08:38| 發布者: 楊炎| 查看: 4623| 評論: 0|原作者: 蠻牛|來自: unity3d腳本manual

摘要: application.loadlevelasync 異步加載關卡static functionloadlevelasync(levelname: string) :asyncoperationdescription描述loads the level asynchronously in the background.在后臺異步加載關卡,也就是說,在 ...

application.loadlevelasync 加載" target="_blank" class="relatedlink">異步加載關卡

static functionloadlevelasync(levelname: string) :asyncoperation

description描述

loads the level asynchronously in the background.

后臺異步加載關卡,也就是說,在后臺非同步加載新的場景。

unity will completely load all assets and all objects in the scene in a background loading thread. this allows you to load new levels while still playing the current one, show a progress bar or create a completely streaming world where you constantly load and unload different parts of the world based on the player position, without any hiccups in game play.

unity將在后臺線程完整加載場景所有資源和物體。這允許你加載一個新的關卡,同時當前的關卡仍在播運行,顯示進度條或者創建一個完整的流世界,在那里你不斷的加載和卸載基于程序位置不同的部分,在游戲中不會有任何的中斷。

isdonevariable from the resultingasyncoperationcan be used to query if the level load has completed. the result of a loadlevelasync can also be used to yield in a coroutine.

isdone變量來自asyncoperation異步操作的結果,可以用于如果關卡加載完成的查詢。

when building a player unity automatically optimizes assets in such a way that loadlevelasync will load them from disk linearly to avoid seek times. note that background loading performance in the unity editor is much lower than in the web player or standalone build. in the editor you might also get more loading hiccups than in the player.

當編譯一個游戲unity自動優化資源,loadlevelasync將從硬盤以線性加載它們避免從磁盤尋道時間。

注意,背景加載優先級在unity編輯器遠遠低于網絡播放器或獨立版編譯。在編輯器你或許也得到比播放器更多的加載中斷。

this function requiresunity pro.

這個函數需運行在unity專業版。

參見:asyncoperation,application.backgroundloadingpriority,application.loadleveladditiveasync.

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

ienumerator start() {

asyncoperation async = application.loadlevelasync("mybiglevel");

yield return async;

debug.log("loading complete");

}

}

function start () {

// load the level named "mybiglevel".

//加載名為mybiglevel的場景

var async : asyncoperation = application.loadlevelasync ("mybiglevel");

yield async;

debug.log("loading complete");

}

相關閱讀

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