gpt4 book ai didi

c# - Unity 5 上的 OnLevelWasLoaded 在哪里?

转载 作者:太空狗 更新时间:2023-10-29 21:16:33 33 4
gpt4 key购买 nike

在这个新的unity版本中,我认为使用了SceneManager。但是我找不到如何在关卡上使用 SceneManager 加载。

老办法:

void OnLevelWasLoaded(){
// do something
}

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

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

不知道要传递什么...

最佳答案

您必须将 sceneLoaded 作为事件。

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

SceneManager.sceneLoaded += this.OnLoadCallback;

加载场景时将调用 OnLoadCallback 函数。

OnLoadCallback 函数签名:

void OnLoadCallback(Scene scene, LoadSceneMode sceneMode)
{

}

关于c# - Unity 5 上的 OnLevelWasLoaded 在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39801130/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com