I am new to scripting, really need some help with using playerprefs
Here is my script
using UnityEngine;
using System.Collections;
public class Score : MonoBehaviour {
public GUIText countText;
public GUIText endText;
public int score;
public int highscore;
void Start()
{
endText.text = "";
countText.text = "Score";
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "PickUp") {
score = score + 1;
SetCountText ();
}
if (other.gameObject.name == "Pick Up2") {
score = score + 4;
SetCountText ();
}
if (other.gameObject.name == "Pick Up3") {
score = score + 9;
SetCountText ();
}
if (other.gameObject.name == "Pick Up4") {
score = score + 19;
SetCountText ();
}
if (other.gameObject.tag == "Player") {
endText.text = "Final Score " + score.ToString ();
}
}
void SetCountText()
{
countText.text = "Score " + score.ToString();
}
void Gameover()
{
if (score > PlayerPrefs.GetInt ("score"))
{
PlayerPrefs.SetInt ("score", highscore);
}
}
void OnGUI ()
{
{
GUI.Label (new Rect(300, 0, 100, 50),"High Score " + highscore);
}
{
if (GUILayout.Button("Restart", GUILayout.Height(50), GUILayout.Width(100)))
Application.LoadLevel (1);
}
}
}