Готовый перевод C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 2.2.2 Scene Manager
Скрипт менеджер контролирует ход игры между физическими сценами. Кнопки из интерфейса меню не сработают в сцене сразу; они попадают на менеджер скриптов сцены ниже, чтобы загрузить их:
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;
}
}
Внимание! Этот перевод, возможно, ещё не готов.
Его статус: идёт перевод
Переведено на Нотабеноиде
http://notabenoid.org/book/55263/242438
Переводчики: ilia1395, Zeke0028
Настройки
Готово:
