- Home /
Saving a variable through loads
I wan't to save a variable through loads, but I'm not too sure how to tackle this. If I have, for example, a string, such as the player's name, how can I have it survive the load so I can use it in a second level?
I saw that GameObject.DontDestroyOnLoad()
can keep a game object for the next level, but what if I have a string for the player to enter their name, as the following shows:
var NAME = "";
function OnGUI() {
NAME = GUI.TextField(Rect(10, 10, 80, 25), NAME, 10);
}
How could I add it to a GameObject, or modify it so that I can have it for the next load?
Comment
Your answer
Follow this Question
Related Questions
Loading last scene 1 Answer
Load scene on button press 4 Answers
Why is first time level load much slower? (iPhone) 2 Answers
Feedback on load & save "system" & how to make a "global"(?) script? 1 Answer