PlayerPrefs.SetString(“PointsScore”, pointsHolder.guiText.text);
PlayerPrefs.SetString(“HealthScore”, healthHolder.guiText.text);
PlayerPrefs.SetString(“MoneyScore”, moneyHolder.guiText.text);
Application.LoadLevel(“final_screen”);
Here I’m directly accessing the guiText object where this data is stored and then sending this data as a string object to the player preferences. In the new scene, I use the following code (excerpted) to get the data out of the system and printed to the screen:
public string finalPointScore;
public string finalHealthScore;
public string finalMoneyScore;
public GameObject geld;
public GameObject gesundheit;
public GameObject punkte;
public void Awake()
{
Screen.showCursor = true;
Screen.lockCursor = false;
finalPointScore = PlayerPrefs.GetString(“PointsScore”);
finalHealthScore = PlayerPrefs.GetString(“HealthScore”);
finalMoneyScore = PlayerPrefs.GetString(“MoneyScore”);
geld = GameObject.Find(“GUITextGeld”);
geld.guiText.text = finalMoneyScore;
geld.gameObject.transform.position = new Vector3(0.14f, 0.517f, 1);
gesundheit = GameObject.Find(“GUITextGesundheit”);
gesundheit.guiText.text = finalHealthScore;
gesundheit.gameObject.transform.position = new Vector3(0.185f, 0.45f, 1);
punkte = GameObject.Find(“GUITextPunkte”);
punkte.guiText.text = finalPointScore;
punkte.gameObject.transform.position = new Vector3(0.145f, 0.38f, 1);
}
Wait, wait, wait! The game is finished?
LikeLike
Well, the prototype version of the game is finished, I suppose. Although there's still a lot I'd like to add (characters, more interface candy), I think that there's enough for me to test it out on students. If I get some grant money, I'll work on developing the game some more. If I don't get grant money, well, I'll probably do the same thing.
LikeLike
Ooh! Ooh! can I help test it?
LikeLike
I'm going to put everything I developed online (game, source code, Blender models, etc.), so you are more than welcome to look at it and see what needs to be changed.
LikeLike