before Unity 5.3, I could do
Application.LoadLevel(Application.loadedLevel);
But now it\'s something weird with SceneManager. I\'ve read d
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);
}
}
it's my C# example:) i had the same problem and now i have figured out with it, you must keep in mind that your scene must be included to the build settings of your project;)
hope this will help others with new canges in it)
Cheers:)
P.S. Add this script to your button in inspector and choose you r script and name of this function:)
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class start_new_game : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
public void Update () {
}
public void OnMouseDown()
{
SceneManager.LoadScene(0);
}
}
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.
using UnityEngine;
using UnityEngine.UI;
using System;
using System.Collections;
**using UnityEngine.SceneManagement;**
public class UIManager : MonoBehaviour{
public void OnRoomJoin(BaseEvent e)
{
// Remove SFS2X listners and re-enable interface before moving to the main game scene
//Reset();
// Goto the main game scene
**SceneManager.LoadScene(1);**
// **SceneManager.LoadScene("main");**
}
}