How to load the same scene?
The scene is now loaded using the Runner.SetActiveScene(levelName) method. I now have a problem: when I restart the scene to load the scene again, it fails to load. I looked at the source code and found that I made a judgment to judge whether the current scene and the scene to be loaded are the same, and if they are the same, return
Best Answer
-
Hi,
The Fusion Scene loading sample showcases how to reload a scene, but it uses a different scene loading logic (multi-scenes). The core that you'll need to understand is that on
NetworkSceneManagerBase
there's this check for saying that the scene is outdated:// store the flag in case scene changes during the load; this supports scene toggling as well if (Runner.CurrentScene != _currentScene) { _currentSceneOutdated = true; }
That's why you can't reload a scene by calling
Runner.SetActiveScene(sameIndex)
. What you could do is add a custom logic to detect a special index (like -1) and set the_currentScenOutdated
to true. Followed by defining the current index back to the actual current index to avoid having a (-1) as index.Notice that you can modify the
NetworkSceneManagerBase
directly, but I recommend doing a copy.Those links may be useful:
https://doc.photonengine.com/en-us/fusion/current/manual/scene-loading
https://doc.photonengine.com/en-us/fusion/current/samples/technical-samples/fusion-scene-loading
-----
Isaac Augusto
Photon Fusion Team
0
Answers
-
Hey, could you please remove the screenshot sharing decompiled Fusion code in public is a big no go. I've asked a colleague to follow up and support you with the issue.
0 -
I removed the code screenshot in the original post.
0 -
Hi,
The Fusion Scene loading sample showcases how to reload a scene, but it uses a different scene loading logic (multi-scenes). The core that you'll need to understand is that on
NetworkSceneManagerBase
there's this check for saying that the scene is outdated:// store the flag in case scene changes during the load; this supports scene toggling as well if (Runner.CurrentScene != _currentScene) { _currentSceneOutdated = true; }
That's why you can't reload a scene by calling
Runner.SetActiveScene(sameIndex)
. What you could do is add a custom logic to detect a special index (like -1) and set the_currentScenOutdated
to true. Followed by defining the current index back to the actual current index to avoid having a (-1) as index.Notice that you can modify the
NetworkSceneManagerBase
directly, but I recommend doing a copy.Those links may be useful:
https://doc.photonengine.com/en-us/fusion/current/manual/scene-loading
https://doc.photonengine.com/en-us/fusion/current/samples/technical-samples/fusion-scene-loading
-----
Isaac Augusto
Photon Fusion Team
0 -
I'm so sorry I didn't know this, I'll follow the rules
0