Skip to content

Instantly share code, notes, and snippets.

@NovaSurfer
Last active March 25, 2018 02:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NovaSurfer/e96f3777ca7a4c46f391634ec65dc695 to your computer and use it in GitHub Desktop.
Save NovaSurfer/e96f3777ca7a4c46f391634ec65dc695 to your computer and use it in GitHub Desktop.
Restart current scene in Unity 5.0 using new SceneManager
/*
For more details, please follow the link below:
https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html
*/
using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;
public class SceneRestart : MonoBehaviour {
void Update () {
if (Input.GetKeyDown(KeyCode.R))
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment