-
Notifications
You must be signed in to change notification settings - Fork 0
/
HighScore.cs
57 lines (48 loc) · 1.33 KB
/
HighScore.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using System.Collections;
using System.Collections.Generic;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.UI;
public class HighScore : MonoBehaviour
{
static private Text _UI_TEXT;
static private int _SCORE = 1000;
private Text txtCom;
// Start is called before the first frame update
void Awake()
{
_UI_TEXT = GetComponent<Text>();
}
static public int SCORE
{
get { return _SCORE;}
private set
{
_SCORE = value;
if (_UI_TEXT != null)
{
if (_UI_TEXT.text != null)
{
_UI_TEXT.text = "High Score: " + value.ToString("#,0");
}
}
}
}
// Update is called once per frame
static public void TRY_SET_HIGH_SCORE(int scoreToTry)
{
if (scoreToTry <= SCORE) return;
SCORE = scoreToTry;
}
[Tooltip("Check this box to reset the High Score in PlayerPrefs")]
public bool resetHighScoreNow = false;
private void OnDrawGizmos()
{
if (resetHighScoreNow)
{
resetHighScoreNow = false;
PlayerPrefs.SetInt("HighScore", 1000);
Debug.LogWarning("PlayerPrefs High Score reset to 1000.");
}
}
}