Unity 5.3如何加载当前级别?

在Unity 5.3之前,我能做到

Application.LoadLevel(Application.loadedLevel); 

但现在使用SceneManager会有些奇怪。 我读过文档但没有。 如何获取当前场景并加载它(Unity 5.3f4)?

谢谢!

使用新的SceneManager并确保包含名称空间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); } } 
 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");** } } 

这是我的C#示例:)我遇到了同样的问题,现在我已经想到了它,你必须记住你的场景必须包含在项目的构建设置中;)希望这将有助于其他人在其中使用新的内容)干杯:)
PS将此脚本添加到检查器中的按钮,然后选择您的脚本和此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); } }