找回密码
 注册帐号

扫一扫,访问微社区

application.loadlevel 加载关卡

2014-12-31 08:26| 发布者: 杨炎| 查看: 3590| 评论: 0|原作者: 蛮牛|来自: unity3d脚本manual

摘要: application.loadlevel 加载关卡static functionloadlevel(index: int) : voiddescription描述loads the level.加载关卡,也就是加载一个新的场景。this function loads level by its index. you can see the indice ...

application.loadlevel 加载关卡

static functionloadlevel(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, useobject.dontdestroyonload.

当加载新的关卡时,所有已经加载的游戏物体都将被销毁。 如果你想让物体在被加 载新关卡时不被销毁,使用object.dontdestroyonload 。

o static functionloadlevel(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.onlevelwasloadedis 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, useobject.dontdestroyonload.

当加载新的关卡时,所有已经加载的游戏物体都将被销毁。 如果你想让物体在加载新关卡时不被销毁,使用object. dontdestroyonload。

相关阅读

文章点评
相关文章