- Home /
calculate playerprefs and display
Ok so i have multiple playerprefs, what i would like to do is add up all the values in my playerprefs and display the final value
i was thinking something like this:
function Update () {
guiText.text = (PlayerPrefs.GetInt("Level81Score"+"Level15Score"+"Level15Score")).ToString ();
}
Answer by Eric5h5 · Feb 22, 2012 at 07:57 AM
Just use GetInt for each entry. You can't combine the strings like that.
Thanx Eic5h5!
Ok iv worked it out myself, my solution is below, probably not the best since im not a coder, hope this helps someone.
static var Count : int = 0;
function Start(){
Count += PlayerPrefs.GetInt("Level1Score"); Count += PlayerPrefs.GetInt("Level2Score"); Count += PlayerPrefs.GetInt("Level3Score");
//Show Score guiText.text = (Count).ToString ();
}
@script RequireComponent (GUIText)
Your answer
Follow this Question
Related Questions
Displaying PlayerPref As Text Using New Unity GUI 1 Answer
GUITime and Score issue. 0 Answers
[Problem] Use Playerpref.GetInt in other thread 0 Answers
Score System help 1 Answer
Score not updating... 1 Answer