before Unity 5.3, I could do
Application.LoadLevel(Application.loadedLevel);
But now it's something weird with SceneManager. I've read documentation but nothing. How do I get the current scene and load it (Unity 5.3f4)?
Thanks!
Another way for loading current scene with SceneMamager is Something Like this : SceneManager. LoadScene(SceneManager. GetActiveScene().
Whenever you want to change scenes you call LoadScene and pass in the name of the scene, which will then add it to the history in addition to changing scenes. Whenever you want to go back to the previous scene you call PreviousScene.
Use the new SceneManager and make sure you include the namespace UnityEngine.SceneManagement
using UnityEngine.SceneManagement;
public class Example
{
public void ReloadCurrentScene()
{
// get the current scene name
string sceneName = SceneManager.GetActiveScene().name;
// load the same scene
SceneManager.LoadScene(sceneName,LoadSceneMode.Single);
}
}
Another way for loading current scene with SceneMamager
is Something Like this :
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
be sure that you have include SceneManager
in your script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With