找回密碼
 注冊帳號

掃一掃,訪問微社區

application.loadlevel 加載關卡

2014-12-31 08:26| 發布者: 楊炎| 查看: 3546| 評論: 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。

相關閱讀

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