333GameStudio

ScoreCounter

Jul 3rd, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma strict
  2.  
  3. var Text : UnityEngine.UI.Text;
  4. var Text1 : UnityEngine.UI.Text;
  5. var Score : int;
  6. var HighScore : int;
  7. function Start(){
  8.  
  9. HighScore = PlayerPrefs.GetInt("Score");
  10.  
  11.  
  12. }
  13. function Update () {
  14.  
  15.  
  16. Text.text = "Score: " + Score;
  17. Text1.text = "HighScore: " + HighScore;
  18.  
  19.  if(Score >= HighScore){
  20.  
  21.  
  22. HighScore = Score;
  23. PlayerPrefs.SetInt("Score",Score);
  24.  
  25. }
  26. }
  27. function FixedUpdate(){
  28. if(Input.GetMouseButton(0)){
  29.  
  30.  
  31. Score = Score + 1;
  32.  
  33.  
  34. }
  35. PlayerPrefs.SetInt("Score",HighScore);
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment