Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class HighscoreSystem : MonoBehaviour
- {
- public Text scoreText;
- public Text highscoreText;
- int score;
- int highscore;
- void Start ()
- {
- score = PlayerPrefs.GetInt("Score");
- highscore = PlayerPrefs.GetInt("Highscore");
- if(score > highscore)
- {
- PlayerPrefs.SetInt("Highscore", score);
- highscore = score;
- }
- scoreText.text = "Score: " + score;
- highscoreText.text = "Highscore: " + highscore;
- PlayerPrefs.SetInt("Score", 0);
- }
- public void RestartGame()
- {
- SceneManager.LoadScene(0);
- }
- }
Add Comment
Please, Sign In to add comment