Advertisement
CakeMeister

gamemaster phan 15

Jul 11th, 2017
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.SceneManagement;
  6.  
  7. public class gamemaster : MonoBehaviour {
  8.     public int points = 0;
  9.     public int highscore = 0;
  10.  
  11.     public Text pointtext;
  12.     public Text Hightext;
  13.     public Text Inputtext;
  14.  
  15.     // Use this for initialization
  16.     void Start () {
  17.         Hightext.text = ("HighScore: " + PlayerPrefs.GetInt("highscore"));
  18.         highscore = PlayerPrefs.GetInt("highscore", 0);
  19.  
  20.         if (PlayerPrefs.HasKey("points"))
  21.         {
  22.             Scene ActiveScreen = SceneManager.GetActiveScene();
  23.             if (ActiveScreen.buildIndex == 0)
  24.             {
  25.                 PlayerPrefs.DeleteKey("points");
  26.                 points = 0;
  27.             }
  28.             else
  29.                 points = PlayerPrefs.GetInt("points");
  30.         }
  31.     }
  32.    
  33.     // Update is called once per frame
  34.     void Update () {
  35.         pointtext.text = ("Points: " + points);
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement