Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Application.LoadLevel 加载关卡
# [Application](Application.html).LoadLevel 加载关卡 static function *LoadLevel* (*index* : int) : void *Description* 描述 Loads the level. 加载关卡,也就是加载一个新的场景。 This function loads level by its index. You can see the indices of all levels using the File->Build Settings... menu in Unity. Before you can load a level you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there. 这个函数按照索引加载关卡。在 Unity 中使用 File->Build Settings.....菜单可以看到所有?关卡的索引列表。在你能过加载关卡之前你必须将它添加到游戏使用关卡列表中。在?Unity 中使用 File->Build Settings.....并添加你需要的关卡到关卡列表中。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { Application.LoadLevel(0); } } ``` ``` // Loads the level with index 0 //加载索引为 0 的关卡 Application.LoadLevel (0); ``` When loading a new level all game objects that have been loaded before are destroyed. If you want to let an object survive when loading a new level, use [Object.DontDestroyOnLoad ](../Object/Object.DontDestroyOnLoad.html). 当加载新的关卡时,所有已经加载的游戏物体都将被销毁。 如果你想让物体在被加?载新关卡时不被销毁,使用 Object.DontDestroyOnLoad 。 • static function *LoadLevel* (*name* : string) : void *Description* 描述 Loads the level by its name. 通过名称加载关卡,也就是说按照名字加载新的场景。 Before you can load a level you have to add it to the list of levels used in the game. Use File->Build Settings... in Unity and add the levels you need to the level list there. [MonoBehaviour.OnLevelWasLoaded ](../MonoBehaviour/MonoBehaviour.OnLevelWasLoaded.html)is called on all active game object's after the level has been loaded. 在你能够加载关卡之前你必须将它添加到游戏使用的关卡列表中。在 Unity 中使用 File->Build Settings..... 并添加你需要的关卡到关卡列表中。关卡被加载所有激活物体上?的 MonoBehaviour . OnLevelWasLoaded 都被调用。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { Application.LoadLevel("HighScore"); } } ``` ``` // Load the level named "HighScore". // 加载名为"HighScore"的关卡。 Application.LoadLevel ("HighScore"); ``` When loading a new level all game objects that have been loaded before are destroyed. If you want to let an object survive when loading a new level, use [Object.DontDestroyOnLoad ](../Object/Object.DontDestroyOnLoad.html). 当加载新的关卡时,所有已经加载的游戏物体都将被销毁。 如果你想让物体在加载新关卡时不被销毁,使用 Object. DontDestroyOnLoad。
da
2022年5月13日 22:59
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码