Question by
ashtopher · Mar 16, 2018 at 04:16 PM ·
c#uiplayerprefsinputfield
Display PlayerPref in InputField
Hi guys, I'm trying to display playerprefs in input fields, but it does not display the playerprefs. I know the playerprefs is fine since I can see it in a console log. But it's not sending it to the input field. I'm not sure what I'm doing wrong. Any advice?
public string playerprefstring;
public InputField textbox;
void Awake () {
// Find mytextbox
textbox = GameObject.Find("mytextbox").GetComponent<InputField> ();
// Put playerprefs into string
playerprefstring = PlayerPrefs.GetString("playerpref1", playerprefvalue);
}
void Update () {
textbox.text = playerprefstring;
}
Comment
Best Answer
Answer by ashtopher · Mar 16, 2018 at 04:42 PM
My bad, the code was fine - it was just because i had some non-existing components that GameObject.Find was trying to find.