找回密碼
 注冊帳號

掃一掃,訪問微社區

application.loadleveladditiveasync 異步累加關卡

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

摘要: application.loadleveladditiveasync 異步累加關卡static functionloadleveladditiveasync(levelname: string) :asyncoperationdescription描述loads the level additively and asynchronously in the background.在 ...

application.loadleveladditiveasync 異步累加關卡

static functionloadleveladditiveasync(levelname: string) :asyncoperation

description描述

loads the level additively and asynchronously in the background.

后臺異步累加關卡,也就是說在后臺非同步加載新的場景,但當前的場景不會被銷毀。

loadlevelasync()和loadleveladditiveasync()的不同在于,前者最終加載完成后,上一個場景內容會被卸載,而后者是兩者重疊到一起

unlikeloadlevelasync, loadleveladditiveasync does not destroy objects in the current level. objects from the new level are added to the current scene. this is useful for creating continuous virtual worlds, where more content is loaded in as you walk through the environment.

不像loadlevelasync,loadleveladditiveasync不銷毀當前關卡的物體。物體從新的關卡添加到當前的場景。這對創建連續的虛擬世界很有用,在你漫步環境,更多的內容被加載進來。

unity will completely load all assets and all objects in the scene in a background loading thread. this allows you to 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 loadleveladditiveasync can also be used toyieldin a coroutine.

isdone變量來自asyncoperation異步操作的結果,可以用于如果關卡加載完成的查詢。loadleveladditiveasync的結果也能在用來yield一個協同程序。

when building a player unity automatically optimizes assets in such a way that loadleveladditiveasync 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.loadlevelasync.

c#

javascript

using unityengine;

using system.collections;

public class example :monobehaviour{

ienumerator start() {

asyncoperation async = application.loadleveladditiveasync("myaddlevel");

yield return async;

debug.log("loading complete");

}

}

function start () {

// load the level named "myaddlevel".

//加載名為myaddlevel的場景

var async : asyncoperation = application.loadleveladditiveasync ("myaddlevel");

yield async;

debug.log("loading complete");

}

相關閱讀

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