SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //insert this as your second line since you're using UI elements
  2. using UnityEngine.UI;
  3. // add this global variable to assign a GameObject in the editor
  4. public Text CountText;
  5. // add this to keep track of the actual score
  6. public static int count;
  7. //add this to void Start()
  8. PlayerPrefs.DeleteAll (); //DELETE THIS LINE AND SEE WHAT HAPPENS
  9. count = PlayerPrefs.GetInt ("High Score", 0);
  10. SetCountText ();
  11. // add this to "listen" for input
  12. void Update() {
  13.     if (Input.GetButtonDown("Fire1")){
  14.         count = count + 1;
  15.         PlayerPrefs.SetInt ("High Score", MainScript.count);
  16.         SetCountText ();
  17.         print (count);
  18.     }
  19. }
  20. //add this to display a dynamic score
  21. void SetCountText(){
  22.     CountText.text = "Flaps: " + MainScript.count.ToString();
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top