C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 2.2.2 Scene Manager

Оглавление
Английский оригинал Перевод на русский

Сожалеем, но текст оригинала доступен только зарегистрированным пользователям.

Скрипт менеджер контролирует ход игры между физическими сценами. Кнопки из интерфейса меню не сработают в сцене сразу; они попадают на менеджер скриптов сцены ниже, чтобы загрузить их:

ilia1395 25.10.14 в 19:48

0

public class SceneManager : MonoBehavior
{
public string[] levelNames;
public int gameLevelNum;
public void Start ()
{ // keep this object alive
DontDestroyOnLoad (this.gameObject);
}
public void LoadLevel( string sceneName )
{ Application.LoadLevel( sceneName );
}
public void GoNextLevel()
{ // if our index goes over the total number of levels in the // array, we reset it if( gameLevelNum >= levelNames.Length )
gameLevelNum = 0;
// load the level (the array index starts at 0, but we start // counting game levels at 1 for clarity’s sake) LoadLevel( gameLevelNum );
// increase our game level index counter
gameLevelNum++;
}
private void LoadLevel( int indexNum )
{ // load the game level LoadLevel( levelNames[indexNum] );
}
public void ResetGame()
{ // reset the level index counter gameLevelNum = 0;
}
}

Zeke0028 25.09.14 в 03:06

0
Минутку...