
1. BestScoreTex추가
2. Playerprefs로 저장 및 불러오기
[SerializeField] private TextMeshProUGUI bestScore_Tex;
private int bestScore;
private void Start()
{
bestScore = PlayerPrefs.GetInt("bestScore");
bestScore_Tex.text = "Best Score : " + bestScore;
}
public void GameOver()
{
SaveBestScore();
}
private void SaveBestScore()
{
if (PlayerPrefs.HasKey("bestScore"))
{
if (score > PlayerPrefs.GetInt("bestScore"))
{
PlayerPrefs.SetInt("bestScore", score);
}
}
else
{
PlayerPrefs.SetInt("bestScore", score);
}
}
3. GameOver시 점수 업데이트 안되도록
```cs
public void GameOver()
{
StopCoroutine("UpdateScore");
}