i5-Toolkit-for-Unity icon indicating copy to clipboard operation
i5-Toolkit-for-Unity copied to clipboard

Scene with name "i5 Persistent Scene" already exists (PersistentScene instead of default DontDestroyOnLoad)

Open romhaviv opened this issue 5 months ago • 0 comments

hi guys, first of all, just wanted to let you know i've been playing with the OpenIDConnectService + GoogleOidcProvider + firebase auth and it works very nicely!

now for the issue

Is your feature request related to a problem? Please describe. I noticed that on scene change, im getting the following errors: Image

ArgumentException: Scene with name "i5 Persistent Scene" already exists
...
Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
The following scene GameObjects were found:
Service Manager Runner

then I started digging in the code and was surprised to see that this toolkit solution for persistency between scenes relies on its own unique solution - "Persistent Scene" (https://rwth-acis.github.io/i5-Toolkit-for-Unity/1.5.0/manual/Utilities/Persistent-Scene.html)

so there's an assumption, that the developers should always use LoadSceneMode.Additive when changing scenes.

in my specific case, the game is already in the default LoadScene implementation + using DontDestroyOnLoad and we would like to keep it this way for now.

Describe the solution you'd like actually I found a "hack" to make it work with the following line: DontDestroyOnLoad(ServiceManager.Instance.Runner.gameObject); but, if it was implemented inside the toolkit with some kind of ServiceManager.DontDestroyOnLoad() or whatever config you feel will be more user-friendly, it would be more nice and less frustrating for developers to realize wdf just happened ( I spent few hours to realize what is going on and solve it... )

Describe alternatives you've considered described above

Additional context described above

thanks, rom

romhaviv avatar Jun 09 '25 00:06 romhaviv