Unity 5上的OnLevelWasLoaded在哪里? [英] Where is OnLevelWasLoaded on Unity 5?

查看:369
本文介绍了Unity 5上的OnLevelWasLoaded在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个新的统一版本中,我认为使用了SceneManager.但是我找不到在已加载SceneManager的级别上做的事情.

In this new unity version, I think SceneManager is used. But I cant find how to do on level was loaded with SceneManager.

旧方法:

void OnLevelWasLoaded(){
// do something
}

当我尝试旧方法时,我会得到这个:

When I try the old way I get this:

在MusicManager上找到

OnLevelWasLoaded 该消息已被弃用,并将在更高版本的Unity中将其删除. 而是将一个代理添加到SceneManager.sceneLoaded中,以在场景加载完成后获取通知

OnLevelWasLoaded was found on MusicManager This message has been deprecated and will be removed in a later version of Unity. Add a delegate to SceneManager.sceneLoaded instead to get notifications after scene loading has completed

我不知道如何使用

SceneManager.sceneLoaded();

不知道该怎么办...

Dont know what to pass...

推荐答案

您必须sceneLoaded作为事件.

Start()Awake()函数中注册sceneLoaded事件.

SceneManager.sceneLoaded += this.OnLoadCallback;

加载场景后,将调用OnLoadCallback函数.

The OnLoadCallback function will then be called when scene is loaded.

OnLoadCallback函数签名:

void OnLoadCallback(Scene scene, LoadSceneMode sceneMode)
{

}

这篇关于Unity 5上的OnLevelWasLoaded在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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