I am just starting out with Unity and I feel like I am getting pretty far, fairly quickly. There is one thing that I do not seem to be grasping: How or where do you store information that should remain persistent? If you Application.LoadLevel(0), and then the player loses a life and accumulates a score of 1000, how do you inform level 1 of the data that was previously held in level 0 when you call Application.LoadLevel(1)?
Is there some sort of repository for information at the Application level that I am not seeing?
Take a scene such as a splashscreen or menu that loads near the start of the game, set DontDestroyOnLoad() so that it never unloads, and attach your globals to a empty game object in that scene.
Thanks Rbn_3D. PlayerPrefs is a great solution and was very easy to implement.
Hoff, I am also interested in the DontDestroyOnLoad() method, because this is more along the lines of what I was initially thinking. What happens to the GameObject when you call it? Or more appropriately, where is it? Is it added to the hierarchy of all loaded levels, or only the currently running one? What if I use LoadLevelAdditive()?
You can create an object in first scene, attach a sript to it and sen value of variable in this script. For example if you want to send user login script attachet to game object that will survife after second scene load should be:
have both scripts in the same Directoy (Not sure if this is nessesary depends on the IDE & Project linkage of files)
set your shared variables as Static Public
use
ScriptName.VariableName = for assignment from another script.