This question was
closed Aug 26, 2016 at 04:12 PM by
Landern for the following reason:
Duplicate question: http://answers.unity3d.com/questions/1235035/highscore-and-playerprefs-unity-c.html
Question by
chesterhilly · Aug 26, 2016 at 04:06 PM ·
c#scoresave datascore systemhighscores
Highscore system unity C#
So I'm not new I but never really worked around scoring with highscores and player prefs. Here is my script and help is greatly appreciated.
I'm very stuck btw, and I have almost no way of knowing how to do highscores.
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Scoring : MonoBehaviour
{
public int highscore;
private float waitTime = 0.25f;
public Text scoreText;
public Text highScoreText;
public int scoreCount = 0;
public bool updateScore = true;
void Score()
{
if (highscore > scoreCount)
{
PlayerPrefs.SetInt("highscore", highscore);
}
}
IEnumerator Highscore()
{
if (highscore < scoreCount)
{
highScoreText.text = "" + scoreCount;
}
StopCoroutine("Highscore");
yield return new WaitForSeconds(0);
}
}
Comment