- Home /
Problems with Playerprefs script
What is wrong with this script?
var savedTForm00 : Transform; private var Scene : String;
function SaveIt00(){///==SAVEIT==/// PlayerPrefs.SetString(Scene); }
function LoadIt00(){///==LOADIT==///
PlayerPrefs.GetString(Scene); } var autoLoad : boolean;
function Start() { if(autoLoad==true) { LoadIt00(); } } function Update() { if(Input.GetKey("m")) { SaveIt00(); } if((Input.GetKey("b"))&&(autoLoad==false)) { LoadIt00(); } }
Answer by spinaljack · Sep 29, 2010 at 11:16 PM
http://unity3d.com/support/documentation/ScriptReference/PlayerPrefs.SetString.html
SetString takes 2 arguments
SetString (key : string, value : string)
Also GetString returns a string, you need to assign it to something, calling GetString on its own does nothing
e.g.
var levelToLoad : String = PlayerPrefs.GetString("savedLevel");
Your answer
Follow this Question
Related Questions
Saving & Loading the scene (or at least one array) via Javascript 1 Answer
Retrieving basic Strings and Ints from XML Files (JS) 0 Answers
Saving and load from player prefs in Unity3D on mobile devices?? 0 Answers
How to efficiently hand out rewards based on the level that the player completed? 3 Answers
Saving Scenes and loading GameObjects? 4 Answers