Search code examples
unity-game-enginerestart

how to restart game using ui button unity 4.6?


I want that the player could play again when they're done playing.

The method works fine when I place it OnGUI(), but when I apply it to an UI button, the restart just hangs and the countdown timer isn't working at all.

public void playAgain(){
    Application.LoadLevel (Application.loadedLevelName);
    Character.score = 0;

    time.second = 30.0f;
}

Solution

  • I believe that you probably set the time.timeScale = 0 when the game ended, and you probably forgot to start it over on the start of the level.