hi im new to unity, ive made a highscore script and it saves with playerprefs perfectly, only problem is that my game has more than one scene and the highscore for one scene is the same for the others, can someone help me in fixing this? im quite new and this is my only problem thats preventing me from finishing my game! thank u in advance
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class ScoreManager : MonoBehaviour
{
public Text scoreText;
public Text hiScoreText;
public float scoreCount;
public float hiScoreCount;
public float pointsPerSecond;
public bool scoreIncreasing;
// Use this for initialization
void Start()
{
if (PlayerPrefs.GetFloat("HighScore") != 0)
{
hiScoreCount = PlayerPrefs.GetFloat("HighScore");
}
}
// Update is called once per frame
void Update()
{
if (scoreIncreasing)
{
scoreCount += pointsPerSecond * Time.deltaTime;
}
if (scoreCount > hiScoreCount)
{
hiScoreCount = scoreCount;
PlayerPrefs.SetFloat("HighScore", hiScoreCount);
PlayerPrefs.Save();
}
scoreText.text = "Score: " + Mathf.Round(scoreCount);
hiScoreText.text = "High Score: " + Mathf.Round(hiScoreCount);
}
}