x


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();
  }
}
more ▼

asked Sep 29 '10 at 11:00 PM

buckethead3495 gravatar image

buckethead3495
52 11 11 16

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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");
more ▼

answered Sep 29 '10 at 11:16 PM

spinaljack gravatar image

spinaljack
9.1k 18 31 92

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3568
x311
x302
x130
x109

asked: Sep 29 '10 at 11:00 PM

Seen: 1321 times

Last Updated: Sep 29 '10 at 11:00 PM