Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Application.LoadLevelAdditiveAsync 异步累加关卡
# [Application](Application.html).LoadLevelAdditiveAsync 异步累加关卡 static function *LoadLevelAdditiveAsync* (*levelName* : string) : [AsyncOperation](../AsyncOperation/AsyncOperation.html) *Description* 描述 Loads the level additively and asynchronously in the background. 在后台异步累加关卡,也就是说在后台非同步加载新的场景,但当前的场景不会被销毁。 LoadLevelAsync()和 LoadLevelAdditiveAsync()的不同在于,前者最终加载完成后,上一个场景内容会被卸载,而后者是两者重叠到一起 Unlike [LoadLevelAsync](Application.LoadLevelAsync.html), 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](Application.LoadLevelAsync.html),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 将在后台线程完整加载场景所有资源和物体。这允许你加载一个新的关卡,同时当前的关卡仍在播运行,显示进度条或者创建一个完整的流世界,在那里你不断的加载和卸载基于程序位置不同的部分,在游戏中不会有任何的中断。 [isDone](../AsyncOperation/AsyncOperation.isDone.html) variable from the resulting [AsyncOperation](../AsyncOperation/AsyncOperation.html) can be used to query if the level load has completed. The result of a LoadLevelAdditiveAsync can also be used to **yield** in a coroutine. isDone 变量来自 [AsyncOperation](../AsyncOperation/AsyncOperation.html) 异步操作的结果,可以用于如果关卡加载完成的查询。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 requires **Unity Pro** . 这个函数需运行在 *Unity 专业版* 。 参见: [AsyncOperation](../AsyncOperation/AsyncOperation.html), [Application.backgroundLoadingPriority](Application.backgroundLoadingPriority.html), [Application.LoadLevelAsync](Application.LoadLevelAsync.html). * [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"); } ```
da
2022年5月13日 23:00
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码