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.
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);
}
}
↧