Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement