Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Scene stores variables after scene reload

$
0
0
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 ![alt text][1] State just before replay button pressed ![alt text][2] 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. [1]: /storage/temp/192042-barrackspreplay.png [2]: /storage/temp/192043-barracksprereplay.png

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>