Found the solution but the fix does not relate to the question raised
Scene stores variables after scene reload
Hello,
Apologies if this question has been raised but I've not found a solution (Not through lack of trying...)
I have a scene that I have a replay button when the player loses/wins. I want to reload the scene and the variables go back to their scene defaults. When I reload the scene, the variables in 2 of my gameobjects are kept as they were at the end of the level, they are not reset. I will show an example below.
State before playing in Editor
State just before replay button pressed
I then call
Scene scene = SceneManager.GetActiveScene(); SceneManager.LoadScene(scene.name);
(I have tried unloading first with unloadsceneasync but same behaviour)
State after reload of scene is the same as the last screenshot, none of these variables are static nor are they in a dontdestroyonload class
Any advice would be much appreciated.