scene-loader
scene-loader copied to clipboard
Request: Transition to Current Scene (Reload Current Scene)
Summary
A way to transition to a copy of the current scene.
Problem or Use Case
Very useful for "restarting a level". Having a single button that no matter what level in your game you are, you can reload it and start from a fresh state.
Proposed Solution
I've achieved it previously (v3.x) by keeping track of the parameters for the last call to TransitionToScene and simply retriggering the last TransitionToScene.
There could also be a way from MySceneManager.GetActiveScene() but I can't find something that works with Addressables (I can't get the addressable back from the active Scene reference)
PS: Amazing v4 overhaul. Pretty close to my boilerplate but much more robust <3
Acknowledgement
- [x] I have searched the existing issues to ensure this feature hasn't been requested already
Hi @miltoncandelero, thank you for opening this issue.
Maybe we could have a method for that, what do you think? Now that you said it, it makes sense to have a way to easily reload scenes. It could also offer the possibility of having an intermediate scene.
I'm thinking of something along these lines:
public Task<SceneResult> ReloadActiveScene(ILoadSceneInfo intermediateScene = null, CancellationToken = default);
Does that align with your proposal?
Also, you mentioned there's no way to get the addressable back from the active scene reference. Would you like to have this possibility as well? Internally we have this information via the ISceneData implementations.
I'm thinking of something along these lines:
public Task<SceneResult> ReloadActiveScene(ILoadSceneInfo intermediateScene = null, CancellationToken = default);
Does that align with your proposal?
Yeah, that's pretty much what I had in mind!
Also, you mentioned there's no way to get the addressable back from the active scene reference. Would you like to have this possibility as well? Internally we have this information via the
ISceneDataimplementations.
I... don't think so? If we solve the reloading internally I am not sure what I could need the Addressable scene for 🤔
We have a deal then. I'll implement this method and start a PR.
Hey @miltoncandelero, sorry for taking so long to open the PR. Could you take a look at it to see if you spot any improvements and opportunities?
I'll merge the PR but feel free to reopen the issue and request improvements if needed.
:tada: This issue has been resolved in version 4.1.0 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket: