当前位置:  开发笔记 > 编程语言 > 正文

Unity 5.3如何加载当前级别?

如何解决《Unity5.3如何加载当前级别?》经验,为你挑选了1个好方法。

在Unity 5.3之前,我可以做到

Application.LoadLevel(Application.loadedLevel);

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

谢谢!



1> JeanLuc..:

使用新的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);
    }
}

推荐阅读
echo7111436
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有