I would like to display a playerprefs.getint variable with a GUIText.
I have a highscoretext GUIText Variable, but it cant work without a ToString() butI can’t but the Tostring in with the playerpref();
highscoretext.text = PlayerPrefs.GetInt("Highscore");
ToString has a load of extension methods for differing types(int32, datetime, object,etc) and doesn’t exist on the PlayerPrefs class.
this should be fine:
highscoretext.text = PlayerPrefs.GetInt("Highscore").ToString();
What happens is that PlayerPrefs.GetInt() is a static method, it can be called anywhere. GetInt returns a variable of type Int before ToString() (this is called chaining) is called which in turn mutates it into a string type. There are other ways of doing this, look into the Convert class for a full stack of converters if you want.