Unity 5.3 如何加载当前关卡? [英] Unity 5.3 How to load current level?

查看:65
本文介绍了Unity 5.3 如何加载当前关卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Unity 5.3 之前,我可以做

before Unity 5.3, I could do

Application.LoadLevel(Application.loadedLevel);

但现在 SceneManager 出现了一些奇怪的现象.我已经阅读了文档,但什么也没有.如何获取当前场景并加载它(Unity 5.3f4)?

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)?

谢谢!

推荐答案

使用新的 SceneManager 并确保包含命名空间 UnityEngine.SceneManagement

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

这篇关于Unity 5.3 如何加载当前关卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆