Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //insert this as your second line since you're using UI elements
- using UnityEngine.UI;
- // add this global variable to assign a GameObject in the editor
- public Text CountText;
- // add this to keep track of the actual score
- public static int count;
- //add this to void Start()
- PlayerPrefs.DeleteAll (); //DELETE THIS LINE AND SEE WHAT HAPPENS
- count = PlayerPrefs.GetInt ("High Score", 0);
- SetCountText ();
- // add this to "listen" for input
- void Update() {
- if (Input.GetButtonDown("Fire1")){
- count = count + 1;
- PlayerPrefs.SetInt ("High Score", MainScript.count);
- SetCountText ();
- print (count);
- }
- }
- //add this to display a dynamic score
- void SetCountText(){
- CountText.text = "Flaps: " + MainScript.count.ToString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement