Okay, I wrote this last night, and it worked then. It no longer does today. The only things I changed were adding a Quit Game button upon death. Code:
public class SetHighScore : MonoBehaviour {
public Text highScore;
public int HighScore;
void Start ()
{
FindObjectOfType().HighScore(); // Calls function which is pasted below.
HighScore = FindObjectOfType().highScore; //Calls integer from the HighScore function.
highScore.text = "HighScore: " + HighScore.ToString(); // Sets HighScore text to integer that was just updated then called. I think.
}
}
Everything is good so far, right? Here is the function called in the first line
public void HighScore ()
{
if (score > PlayerPrefs.GetInt("HighScore", 0))
{
PlayerPrefs.SetInt("HighScore", score); // Sets highscore.
highScore = PlayerPrefs.GetInt("HighScore"); //sets integer to new high score.
}
}
I know that the Start funtion being used is not the issue, as the GameObject that this script rests on is only enabled upon death. Sorry if this post is hard to follow. If you need any more info, just ask ^.^
↧