- Home /
Duplicate Question
what is better using dontdestroyonload or making the variable static ?
im just curious which is more efficient, im just making a breakout clone and i want the current lives to be passed to the next stage
Is currentLives the only variable you want to remember between scenes? I would say just store the lives in PlayerPrefs. Save the currentLives to PlayerPrefs before loading the next level, and at the start of the next level just load currentLives from PlayerPrefs.
well i have a manager script that is holding score, currentLives, and brick number, they are currently all static.
im kinda of a noob at unity, how do i use playerprefs?
static will only keep the properties that are static, while DontDestroyOnLoad will keep everything related to the object. PlayerPrefs is probably the way to go... since you can also use it as an Auto-save feature. as for playerprefs, I googled these random results. some docs to...
http://docs.unity3d.com/Documentation/ScriptReference/PlayerPrefs.html
http://www.3dbuzz.com/forum/threads/188619-Ho-To-create-save-amp-Load-point-on-unity-game
im actually following that guy you linked me too on youtube to make the brick game. Which is where i got the idea of using static variables to move variables to another scene