When my game ends I want it to automatically restart from the beginning so that the whole scene repeats itself. How do I do that in Unity 3D?
Please refer this link for clarification.
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityTo restart your current scene, you need current scene index or name. And once you have the current scene index or name then just reload it. Here the example that how i done it:
public void RestartCurrentScene()
{
int currentScene = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentScene);
}
Add this to the very top section of the script. As it is required by "SceneManager".
using UnityEngine.SceneManagement;
I hope this will help...
you can use this code:
UnityEngine.SceneManagement.SceneManager.LoadScene( UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
SceneManager.LoadScene(0);
might interest you \$\endgroup\$