Unity 5.3 How to load current level?

后端 未结 4 708
暗喜
暗喜 2020-12-11 01:14

before Unity 5.3, I could do

Application.LoadLevel(Application.loadedLevel);

But now it\'s something weird with SceneManager. I\'ve read d

4条回答
  •  甜味超标
    2020-12-11 01:20

    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);
        }
    }
    

提交回复
热议问题