- Home /
Displaying PlayerPref As Text Using New Unity GUI
I just upgraded to unity 5 and i'm having trouble understanding how to use the new GUI. I'd like to use it instead of the legacy one but I'm not quite understanding how it works and the tutorials i've watched don't seem to be helping.
basically i just want the new GUI Text to display how much money the player has which is taken from a playerpref called GoldAmount.
Answer by alexi123454 · Jul 22, 2015 at 07:16 PM
You would have to do some coding for that. Just create a simple script like this:
public Text goldText;
void Update()
{
goldText.text = PlayerPrefs.GetInt("GoldAmount").ToString();
}
and place it on an object in your scene. Make sure to point the goldText variable to the UI Text gameObject.
@smiler3650 Good, that's all that code does. It retrieves an integer from playerprefs, and converts it to a string to display on a text object.
Your answer
Follow this Question
Related Questions
Can't display PNG texture within GUI calls 1 Answer
How do I display the PlayerPrefs? 1 Answer
How do i make a (Working) health bar 1 Answer
Something is missing in my code can any body help me? 0 Answers
GUI looks Awful! 0 Answers